1 ; Test that we correctly import an indir resolution for type identifier "typeid1".
2 ; RUN: opt -S -passes=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: Visibility: 0
9 ; SUMMARY-NEXT: NotEligibleToImport: false
10 ; SUMMARY-NEXT: Live: true
11 ; SUMMARY-NEXT: Local: false
12 ; SUMMARY-NEXT: CanAutoHide: false
13 ; SUMMARY-NEXT: TypeTestAssumeVCalls:
14 ; SUMMARY-NEXT: - GUID: 123
15 ; SUMMARY-NEXT: Offset: 0
16 ; SUMMARY-NEXT: - GUID: 456
17 ; SUMMARY-NEXT: Offset: 4
18 ; SUMMARY-NEXT: TypeCheckedLoadVCalls:
19 ; SUMMARY-NEXT: - GUID: 789
20 ; SUMMARY-NEXT: Offset: 8
21 ; SUMMARY-NEXT: - GUID: 1234
22 ; SUMMARY-NEXT: Offset: 16
23 ; SUMMARY-NEXT: TypeTestAssumeConstVCalls:
24 ; SUMMARY-NEXT: - VFunc:
25 ; SUMMARY-NEXT: GUID: 123
26 ; SUMMARY-NEXT: Offset: 4
27 ; SUMMARY-NEXT: Args: [ 12, 24 ]
28 ; SUMMARY-NEXT: TypeCheckedLoadConstVCalls:
29 ; SUMMARY-NEXT: - VFunc:
30 ; SUMMARY-NEXT: GUID: 456
31 ; SUMMARY-NEXT: Offset: 8
32 ; SUMMARY-NEXT: Args: [ 24, 12 ]
33 ; SUMMARY-NEXT: TypeIdMap:
34 ; SUMMARY-NEXT: typeid1:
35 ; SUMMARY-NEXT: TTRes:
36 ; SUMMARY-NEXT: Kind: Unknown
37 ; SUMMARY-NEXT: SizeM1BitWidth: 0
38 ; SUMMARY-NEXT: AlignLog2: 0
39 ; SUMMARY-NEXT: SizeM1: 0
40 ; SUMMARY-NEXT: BitMask: 0
41 ; SUMMARY-NEXT: InlineBits: 0
42 ; SUMMARY-NEXT: WPDRes:
44 ; SUMMARY-NEXT: Kind: Indir
45 ; SUMMARY-NEXT: SingleImplName: ''
46 ; SUMMARY-NEXT: ResByArg:
48 ; SUMMARY-NEXT: Kind: Indir
49 ; SUMMARY-NEXT: SingleImplName: ''
50 ; SUMMARY-NEXT: ResByArg:
52 ; SUMMARY-NEXT: Kind: UniformRetVal
53 ; SUMMARY-NEXT: Info: 12
54 ; SUMMARY-NEXT: Byte: 0
55 ; SUMMARY-NEXT: Bit: 0
57 ; SUMMARY-NEXT: Kind: UniformRetVal
58 ; SUMMARY-NEXT: Info: 24
59 ; SUMMARY-NEXT: Byte: 0
60 ; SUMMARY-NEXT: Bit: 0
61 ; SUMMARY-NEXT: 12,24:
62 ; SUMMARY-NEXT: Kind: UniformRetVal
63 ; SUMMARY-NEXT: Info: 48
64 ; SUMMARY-NEXT: Byte: 0
65 ; SUMMARY-NEXT: Bit: 0
67 target datalayout = "e-p:32:32"
69 declare void @llvm.assume(i1)
70 declare void @llvm.trap()
71 declare {i8*, i1} @llvm.type.checked.load(i8*, i32, metadata)
72 declare i1 @llvm.type.test(i8*, metadata)
74 ; CHECK: define i1 @f1
75 define i1 @f1(i8* %obj) {
76 %vtableptr = bitcast i8* %obj to [1 x i8*]**
77 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
78 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
79 %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid1")
80 call void @llvm.assume(i1 %p)
81 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
82 %fptr = load i8*, i8** %fptrptr
83 %fptr_casted = bitcast i8* %fptr to i1 (i8*, i32)*
85 %result = call i1 %fptr_casted(i8* %obj, i32 5)
89 ; CHECK: define i1 @f2
90 define i1 @f2(i8* %obj) {
91 %vtableptr = bitcast i8* %obj to [1 x i8*]**
92 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
93 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
94 %pair = call {i8*, i1} @llvm.type.checked.load(i8* %vtablei8, i32 4, metadata !"typeid1")
95 %fptr = extractvalue {i8*, i1} %pair, 0
96 %p = extractvalue {i8*, i1} %pair, 1
97 ; CHECK: [[P:%.*]] = call i1 @llvm.type.test
99 br i1 %p, label %cont, label %trap
102 %fptr_casted = bitcast i8* %fptr to i1 (i8*, i32)*
104 %result = call i1 %fptr_casted(i8* %obj, i32 undef)
108 call void @llvm.trap()