Bump version to 19.1.0-rc3
[llvm-project.git] / llvm / test / Transforms / WholeProgramDevirt / import-indir.ll
blobe4d6f1d52b540d93dd9d77a11dd4713ede8a46e1
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:
6 ; SUMMARY-NEXT:  42:
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:      ImportType:          0
14 ; SUMMARY-NEXT:      TypeTestAssumeVCalls:
15 ; SUMMARY-NEXT:        - GUID:            123
16 ; SUMMARY-NEXT:          Offset:          0
17 ; SUMMARY-NEXT:        - GUID:            456
18 ; SUMMARY-NEXT:          Offset:          4
19 ; SUMMARY-NEXT:      TypeCheckedLoadVCalls:
20 ; SUMMARY-NEXT:        - GUID:            789
21 ; SUMMARY-NEXT:          Offset:          8
22 ; SUMMARY-NEXT:        - GUID:            1234
23 ; SUMMARY-NEXT:          Offset:          16
24 ; SUMMARY-NEXT:      TypeTestAssumeConstVCalls:
25 ; SUMMARY-NEXT:        - VFunc:
26 ; SUMMARY-NEXT:            GUID:            123
27 ; SUMMARY-NEXT:            Offset:          4
28 ; SUMMARY-NEXT:          Args: [ 12, 24 ]
29 ; SUMMARY-NEXT:      TypeCheckedLoadConstVCalls:
30 ; SUMMARY-NEXT:        - VFunc:
31 ; SUMMARY-NEXT:            GUID:            456
32 ; SUMMARY-NEXT:            Offset:          8
33 ; SUMMARY-NEXT:          Args: [ 24, 12 ]
34 ; SUMMARY-NEXT: 43:
35 ; SUMMARY-NEXT:   - Linkage:                0
36 ; SUMMARY-NEXT:     Visibility:             0
37 ; SUMMARY-NEXT:     NotEligibleToImport:   false
38 ; SUMMARY-NEXT:     Live:                  true
39 ; SUMMARY-NEXT:     Local:                 false
40 ; SUMMARY-NEXT:     CanAutoHide:           false
41 ; SUMMARY-NEXT:     ImportType:            1
42 ; SUMMARY-NEXT: TypeIdMap:
43 ; SUMMARY-NEXT:   typeid1:
44 ; SUMMARY-NEXT:     TTRes:
45 ; SUMMARY-NEXT:       Kind:            Unknown
46 ; SUMMARY-NEXT:       SizeM1BitWidth:  0
47 ; SUMMARY-NEXT:       AlignLog2:       0
48 ; SUMMARY-NEXT:       SizeM1:          0
49 ; SUMMARY-NEXT:       BitMask:         0
50 ; SUMMARY-NEXT:       InlineBits:      0
51 ; SUMMARY-NEXT:     WPDRes:
52 ; SUMMARY-NEXT:       0:
53 ; SUMMARY-NEXT:         Kind:            Indir
54 ; SUMMARY-NEXT:         SingleImplName:  ''
55 ; SUMMARY-NEXT:         ResByArg:
56 ; SUMMARY-NEXT:       4:
57 ; SUMMARY-NEXT:         Kind:            Indir
58 ; SUMMARY-NEXT:         SingleImplName:  ''
59 ; SUMMARY-NEXT:         ResByArg:
60 ; SUMMARY-NEXT:           :
61 ; SUMMARY-NEXT:             Kind:            UniformRetVal
62 ; SUMMARY-NEXT:             Info:            12
63 ; SUMMARY-NEXT:             Byte:            0
64 ; SUMMARY-NEXT:             Bit:             0
65 ; SUMMARY-NEXT:           12:
66 ; SUMMARY-NEXT:             Kind:            UniformRetVal
67 ; SUMMARY-NEXT:             Info:            24
68 ; SUMMARY-NEXT:             Byte:            0
69 ; SUMMARY-NEXT:             Bit:             0
70 ; SUMMARY-NEXT:           12,24:
71 ; SUMMARY-NEXT:             Kind:            UniformRetVal
72 ; SUMMARY-NEXT:             Info:            48
73 ; SUMMARY-NEXT:             Byte:            0
74 ; SUMMARY-NEXT:             Bit:             0
76 target datalayout = "e-p:32:32"
78 declare void @llvm.assume(i1)
79 declare void @llvm.trap()
80 declare {ptr, i1} @llvm.type.checked.load(ptr, i32, metadata)
81 declare i1 @llvm.type.test(ptr, metadata)
83 ; CHECK: define i1 @f1
84 define i1 @f1(ptr %obj) {
85   %vtable = load ptr, ptr %obj
86   %p = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid1")
87   call void @llvm.assume(i1 %p)
88   %fptr = load ptr, ptr %vtable
89   ; CHECK: call i1 %
90   %result = call i1 %fptr(ptr %obj, i32 5)
91   ret i1 %result
94 ; CHECK: define i1 @f2
95 define i1 @f2(ptr %obj) {
96   %vtable = load ptr, ptr %obj
97   %pair = call {ptr, i1} @llvm.type.checked.load(ptr %vtable, i32 4, metadata !"typeid1")
98   %fptr = extractvalue {ptr, i1} %pair, 0
99   %p = extractvalue {ptr, i1} %pair, 1
100   ; CHECK: [[P:%.*]] = call i1 @llvm.type.test
101   ; CHECK: br i1 [[P]]
102   br i1 %p, label %cont, label %trap
104 cont:
105   ; CHECK: call i1 %
106   %result = call i1 %fptr(ptr %obj, i32 undef)
107   ret i1 %result
109 trap:
110   call void @llvm.trap()
111   unreachable