1 ; Test that we correctly import an indir resolution for type identifier "typeid1".
2 ; RUN: opt -S -wholeprogramdevirt -wholeprogramdevirt-summary-action=import -wholeprogramdevirt-read-summary=%S/Inputs/import-indir.yaml -wholeprogramdevirt-write-summary=%t < %s | FileCheck %s
3 ; RUN: FileCheck --check-prefix=SUMMARY %s < %t
5 ; SUMMARY: GlobalValueMap:
7 ; SUMMARY-NEXT: - Linkage: 0
8 ; SUMMARY-NEXT: NotEligibleToImport: false
9 ; SUMMARY-NEXT: Live: true
10 ; SUMMARY-NEXT: Local: false
11 ; SUMMARY-NEXT: CanAutoHide: false
12 ; SUMMARY-NEXT: TypeTestAssumeVCalls:
13 ; SUMMARY-NEXT: - GUID: 123
14 ; SUMMARY-NEXT: Offset: 0
15 ; SUMMARY-NEXT: - GUID: 456
16 ; SUMMARY-NEXT: Offset: 4
17 ; SUMMARY-NEXT: TypeCheckedLoadVCalls:
18 ; SUMMARY-NEXT: - GUID: 789
19 ; SUMMARY-NEXT: Offset: 8
20 ; SUMMARY-NEXT: - GUID: 1234
21 ; SUMMARY-NEXT: Offset: 16
22 ; SUMMARY-NEXT: TypeTestAssumeConstVCalls:
23 ; SUMMARY-NEXT: - VFunc:
24 ; SUMMARY-NEXT: GUID: 123
25 ; SUMMARY-NEXT: Offset: 4
26 ; SUMMARY-NEXT: Args: [ 12, 24 ]
27 ; SUMMARY-NEXT: TypeCheckedLoadConstVCalls:
28 ; SUMMARY-NEXT: - VFunc:
29 ; SUMMARY-NEXT: GUID: 456
30 ; SUMMARY-NEXT: Offset: 8
31 ; SUMMARY-NEXT: Args: [ 24, 12 ]
32 ; SUMMARY-NEXT: TypeIdMap:
33 ; SUMMARY-NEXT: typeid1:
34 ; SUMMARY-NEXT: TTRes:
35 ; SUMMARY-NEXT: Kind: Unsat
36 ; SUMMARY-NEXT: SizeM1BitWidth: 0
37 ; SUMMARY-NEXT: AlignLog2: 0
38 ; SUMMARY-NEXT: SizeM1: 0
39 ; SUMMARY-NEXT: BitMask: 0
40 ; SUMMARY-NEXT: InlineBits: 0
41 ; SUMMARY-NEXT: WPDRes:
43 ; SUMMARY-NEXT: Kind: Indir
44 ; SUMMARY-NEXT: SingleImplName: ''
45 ; SUMMARY-NEXT: ResByArg:
47 ; SUMMARY-NEXT: Kind: Indir
48 ; SUMMARY-NEXT: SingleImplName: ''
49 ; SUMMARY-NEXT: ResByArg:
51 ; SUMMARY-NEXT: Kind: UniformRetVal
52 ; SUMMARY-NEXT: Info: 12
53 ; SUMMARY-NEXT: Byte: 0
54 ; SUMMARY-NEXT: Bit: 0
56 ; SUMMARY-NEXT: Kind: UniformRetVal
57 ; SUMMARY-NEXT: Info: 24
58 ; SUMMARY-NEXT: Byte: 0
59 ; SUMMARY-NEXT: Bit: 0
60 ; SUMMARY-NEXT: 12,24:
61 ; SUMMARY-NEXT: Kind: UniformRetVal
62 ; SUMMARY-NEXT: Info: 48
63 ; SUMMARY-NEXT: Byte: 0
64 ; SUMMARY-NEXT: Bit: 0
66 target datalayout = "e-p:32:32"
68 declare void @llvm.assume(i1)
69 declare void @llvm.trap()
70 declare {i8*, i1} @llvm.type.checked.load(i8*, i32, metadata)
71 declare i1 @llvm.type.test(i8*, metadata)
73 ; CHECK: define i1 @f1
74 define i1 @f1(i8* %obj) {
75 %vtableptr = bitcast i8* %obj to [1 x i8*]**
76 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
77 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
78 %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid1")
79 call void @llvm.assume(i1 %p)
80 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
81 %fptr = load i8*, i8** %fptrptr
82 %fptr_casted = bitcast i8* %fptr to i1 (i8*, i32)*
84 %result = call i1 %fptr_casted(i8* %obj, i32 5)
88 ; CHECK: define i1 @f2
89 define i1 @f2(i8* %obj) {
90 %vtableptr = bitcast i8* %obj to [1 x i8*]**
91 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
92 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
93 %pair = call {i8*, i1} @llvm.type.checked.load(i8* %vtablei8, i32 4, metadata !"typeid1")
94 %fptr = extractvalue {i8*, i1} %pair, 0
95 %p = extractvalue {i8*, i1} %pair, 1
96 ; CHECK: [[P:%.*]] = call i1 @llvm.type.test
98 br i1 %p, label %cont, label %trap
101 %fptr_casted = bitcast i8* %fptr to i1 (i8*, i32)*
103 %result = call i1 %fptr_casted(i8* %obj, i32 undef)
107 call void @llvm.trap()