1 ; REQUIRES: x86-registered-target
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.
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
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
17 ; DIS-NOT: typeidMetadata
19 ; Legacy PM, Index based WPD
20 ; RUN: llvm-lto2 run %t2.o -save-temps -pass-remarks=. \
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
26 ; New PM, Index based WPD
27 ; RUN: llvm-lto2 run %t2.o -save-temps -use-new-pm -pass-remarks=. \
29 ; RUN: -r=%t2.o,test,plx \
30 ; RUN: -r=%t2.o,_ZN1D1mEi,
31 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
33 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
34 target triple = "x86_64-grtev4-linux-gnu"
36 %struct.D = type { i32 (...)** }
38 @_ZTV1D = internal constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* undef, i8* bitcast (i32 (%struct.D*, i32)* @_ZN1D1mEi to i8*)] }, !type !3
40 ; CHECK-IR-LABEL: define weak_odr dso_local i32 @test
41 define weak_odr i32 @test(%struct.D* %obj2, i32 %a) {
43 %0 = bitcast %struct.D* %obj2 to i8***
44 %vtable2 = load i8**, i8*** %0
45 %1 = bitcast i8** %vtable2 to i8*
46 %p2 = call i1 @llvm.type.test(i8* %1, metadata !4)
47 call void @llvm.assume(i1 %p2)
49 %2 = bitcast i8** %vtable2 to i32 (%struct.D*, i32)**
50 %fptr33 = load i32 (%struct.D*, i32)*, i32 (%struct.D*, i32)** %2, align 8
52 ; Check that the call was not devirtualized.
53 ; CHECK-IR: %call4 = tail call i32 %fptr33
54 %call4 = tail call i32 %fptr33(%struct.D* nonnull %obj2, i32 0)
57 ; CHECK-IR-LABEL: ret i32
60 declare i1 @llvm.type.test(i8*, metadata)
61 declare void @llvm.assume(i1)
63 declare i32 @_ZN1D1mEi(%struct.D* %this, i32 %a)