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, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @g, ptr null }] 30 31%struct.D = type { ptr } 32 33@_ZTV1D = internal constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr undef, ptr @_ZN1D1mEi] }, !type !3 34 35; CHECK-IR-LABEL: define weak_odr dso_local i32 @test 36define weak_odr i32 @test(ptr %obj2, i32 %a) { 37entry: 38 %vtable2 = load ptr, ptr %obj2 39 %p2 = call i1 @llvm.type.test(ptr %vtable2, metadata !4) 40 call void @llvm.assume(i1 %p2) 41 42 %fptr33 = load ptr, ptr %vtable2, align 8 43 44 ; Check that the call was not devirtualized. 45 ; CHECK-IR: %call4 = tail call i32 %fptr33 46 %call4 = tail call i32 %fptr33(ptr nonnull %obj2, i32 0) 47 ret i32 %call4 48} 49; CHECK-IR-LABEL: ret i32 50; CHECK-IR-LABEL: } 51 52; Function Attrs: inlinehint nounwind uwtable 53define internal void @_ZN1DC2Ev(ptr %this) unnamed_addr align 2 { 54entry: 55 %this.addr = alloca ptr, align 8 56 store ptr %this, ptr %this.addr, align 8 57 %this1 = load ptr, ptr %this.addr 58 store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1D, i64 0, i32 0, i64 2), ptr %this1, align 8 59 ret void 60} 61 62define internal void @g() section ".text.startup" { 63 %d = alloca %struct.D, align 8 64 call void @_ZN1DC2Ev(ptr %d) 65 ret void 66} 67 68declare i1 @llvm.type.test(ptr, metadata) 69declare void @llvm.assume(i1) 70 71declare i32 @_ZN1D1mEi(ptr %this, i32 %a) 72 73!3 = !{i64 16, !4} 74!4 = distinct !{} 75