1; REQUIRES: x86-registered-target 2 3; Test that index-only devirtualization handles and ignores any 4; type metadata that could not be summarized (because it was internal 5; and could not be promoted due to the fact that the module has 6; no external symbols and therefore could not be assigned a unique 7; identifier). In this case we should simply not get the type 8; metadata summary entries, and no promotion will occur. 9 10; Generate unsplit module with summary for ThinLTO index-based WPD. 11; RUN: opt -thinlto-bc -thinlto-split-lto-unit=false -o %t2.o %s 12 13; Check that we don't have module flag when splitting not enabled for ThinLTO, 14; and that we generate summary information needed for index-based WPD. 15; RUN: llvm-dis -o - %t2.o | FileCheck %s --check-prefix=DIS 16; DIS-NOT: typeIdInfo 17; DIS-NOT: typeidMetadata 18 19; Index based WPD 20; RUN: llvm-lto2 run %t2.o -save-temps -pass-remarks=. \ 21; RUN: -o %t3 \ 22; RUN: -r=%t2.o,test,plx \ 23; RUN: -r=%t2.o,_ZN1D1mEi, 24; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR 25 26target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 27target triple = "x86_64-grtev4-linux-gnu" 28 29@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @g, i8* null }] 30 31%struct.D = type { i32 (...)** } 32 33@_ZTV1D = internal constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* undef, i8* bitcast (i32 (%struct.D*, i32)* @_ZN1D1mEi to i8*)] }, !type !3 34 35; CHECK-IR-LABEL: define weak_odr dso_local i32 @test 36define weak_odr i32 @test(%struct.D* %obj2, i32 %a) { 37entry: 38 %0 = bitcast %struct.D* %obj2 to i8*** 39 %vtable2 = load i8**, i8*** %0 40 %1 = bitcast i8** %vtable2 to i8* 41 %p2 = call i1 @llvm.type.test(i8* %1, metadata !4) 42 call void @llvm.assume(i1 %p2) 43 44 %2 = bitcast i8** %vtable2 to i32 (%struct.D*, i32)** 45 %fptr33 = load i32 (%struct.D*, i32)*, i32 (%struct.D*, i32)** %2, align 8 46 47 ; Check that the call was not devirtualized. 48 ; CHECK-IR: %call4 = tail call i32 %fptr33 49 %call4 = tail call i32 %fptr33(%struct.D* nonnull %obj2, i32 0) 50 ret i32 %call4 51} 52; CHECK-IR-LABEL: ret i32 53; CHECK-IR-LABEL: } 54 55; Function Attrs: inlinehint nounwind uwtable 56define internal void @_ZN1DC2Ev(%struct.D* %this) unnamed_addr align 2 { 57entry: 58 %this.addr = alloca %struct.D*, align 8 59 store %struct.D* %this, %struct.D** %this.addr, align 8 60 %this1 = load %struct.D*, %struct.D** %this.addr 61 %0 = bitcast %struct.D* %this1 to i32 (...)*** 62 store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1D, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 63 ret void 64} 65 66define internal void @g() section ".text.startup" { 67 %d = alloca %struct.D, align 8 68 call void @_ZN1DC2Ev(%struct.D* %d) 69 ret void 70} 71 72declare i1 @llvm.type.test(i8*, metadata) 73declare void @llvm.assume(i1) 74 75declare i32 @_ZN1D1mEi(%struct.D* %this, i32 %a) 76 77!3 = !{i64 16, !4} 78!4 = distinct !{} 79