1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown-linux < %s | FileCheck %s
3 ; RUN: llc -verify-machineinstrs -mtriple=i386-unknown-linux < %s | FileCheck %s --check-prefix=CHECK-32BIT
5 ; Check CSR split can work properly for tests below.
7 @a = common dso_local local_unnamed_addr global i32 0, align 4
9 define dso_local signext i32 @test1(ptr %b) local_unnamed_addr {
11 ; CHECK: # %bb.0: # %entry
12 ; CHECK-NEXT: movslq a(%rip), %rax
13 ; CHECK-NEXT: cmpq %rdi, %rax
14 ; CHECK-NEXT: je .LBB0_2
15 ; CHECK-NEXT: # %bb.1: # %if.end
17 ; CHECK-NEXT: .LBB0_2: # %if.then
18 ; CHECK-NEXT: pushq %rbx
19 ; CHECK-NEXT: .cfi_def_cfa_offset 16
20 ; CHECK-NEXT: .cfi_offset %rbx, -16
21 ; CHECK-NEXT: movq %rdi, %rbx
22 ; CHECK-NEXT: callq callVoid@PLT
23 ; CHECK-NEXT: movq %rbx, %rdi
24 ; CHECK-NEXT: popq %rbx
25 ; CHECK-NEXT: .cfi_def_cfa_offset 8
26 ; CHECK-NEXT: jmp callNonVoid@PLT # TAILCALL
28 ; CHECK-32BIT-LABEL: test1:
29 ; CHECK-32BIT: # %bb.0: # %entry
30 ; CHECK-32BIT-NEXT: subl $12, %esp
31 ; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 16
32 ; CHECK-32BIT-NEXT: movl {{[0-9]+}}(%esp), %eax
33 ; CHECK-32BIT-NEXT: cmpl %eax, a
34 ; CHECK-32BIT-NEXT: je .LBB0_2
35 ; CHECK-32BIT-NEXT: # %bb.1: # %if.end
36 ; CHECK-32BIT-NEXT: addl $12, %esp
37 ; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 4
38 ; CHECK-32BIT-NEXT: retl
39 ; CHECK-32BIT-NEXT: .LBB0_2: # %if.then
40 ; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 16
41 ; CHECK-32BIT-NEXT: calll callVoid@PLT
42 ; CHECK-32BIT-NEXT: addl $12, %esp
43 ; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 4
44 ; CHECK-32BIT-NEXT: jmp callNonVoid@PLT # TAILCALL
46 %0 = load i32, ptr @a, align 4, !tbaa !2
47 %conv = sext i32 %0 to i64
48 %1 = inttoptr i64 %conv to ptr
49 %cmp = icmp eq ptr %1, %b
50 br i1 %cmp, label %if.then, label %if.end
52 if.then: ; preds = %entry
53 %call = tail call signext i32 @callVoid()
54 %call2 = tail call signext i32 @callNonVoid(ptr %b)
57 if.end: ; preds = %if.then, %entry
58 %retval.0 = phi i32 [ %call2, %if.then ], [ undef, %entry ]
62 declare signext i32 @callVoid(...) local_unnamed_addr
64 declare signext i32 @callNonVoid(ptr) local_unnamed_addr
66 define dso_local signext i32 @test2(ptr %p1) local_unnamed_addr {
68 ; CHECK: # %bb.0: # %entry
69 ; CHECK-NEXT: testq %rdi, %rdi
70 ; CHECK-NEXT: je .LBB1_2
71 ; CHECK-NEXT: # %bb.1: # %if.end
72 ; CHECK-NEXT: movslq a(%rip), %rax
73 ; CHECK-NEXT: cmpq %rdi, %rax
74 ; CHECK-NEXT: je .LBB1_3
75 ; CHECK-NEXT: .LBB1_2: # %return
76 ; CHECK-NEXT: xorl %eax, %eax
78 ; CHECK-NEXT: .LBB1_3: # %if.then2
79 ; CHECK-NEXT: pushq %rbx
80 ; CHECK-NEXT: .cfi_def_cfa_offset 16
81 ; CHECK-NEXT: .cfi_offset %rbx, -16
82 ; CHECK-NEXT: movq %rdi, %rbx
83 ; CHECK-NEXT: callq callVoid@PLT
84 ; CHECK-NEXT: movq %rbx, %rdi
85 ; CHECK-NEXT: popq %rbx
86 ; CHECK-NEXT: .cfi_def_cfa_offset 8
87 ; CHECK-NEXT: jmp callNonVoid@PLT # TAILCALL
89 ; CHECK-32BIT-LABEL: test2:
90 ; CHECK-32BIT: # %bb.0: # %entry
91 ; CHECK-32BIT-NEXT: subl $12, %esp
92 ; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 16
93 ; CHECK-32BIT-NEXT: movl {{[0-9]+}}(%esp), %eax
94 ; CHECK-32BIT-NEXT: testl %eax, %eax
95 ; CHECK-32BIT-NEXT: je .LBB1_2
96 ; CHECK-32BIT-NEXT: # %bb.1: # %if.end
97 ; CHECK-32BIT-NEXT: cmpl %eax, a
98 ; CHECK-32BIT-NEXT: je .LBB1_3
99 ; CHECK-32BIT-NEXT: .LBB1_2: # %return
100 ; CHECK-32BIT-NEXT: xorl %eax, %eax
101 ; CHECK-32BIT-NEXT: addl $12, %esp
102 ; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 4
103 ; CHECK-32BIT-NEXT: retl
104 ; CHECK-32BIT-NEXT: .LBB1_3: # %if.then2
105 ; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 16
106 ; CHECK-32BIT-NEXT: calll callVoid@PLT
107 ; CHECK-32BIT-NEXT: addl $12, %esp
108 ; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 4
109 ; CHECK-32BIT-NEXT: jmp callNonVoid@PLT # TAILCALL
111 %tobool = icmp eq ptr %p1, null
112 br i1 %tobool, label %return, label %if.end
114 if.end: ; preds = %entry
115 %0 = load i32, ptr @a, align 4, !tbaa !2
116 %conv = sext i32 %0 to i64
117 %1 = inttoptr i64 %conv to ptr
118 %cmp = icmp eq ptr %1, %p1
119 br i1 %cmp, label %if.then2, label %return
121 if.then2: ; preds = %if.end
122 %call = tail call signext i32 @callVoid()
123 %call3 = tail call signext i32 @callNonVoid(ptr nonnull %p1)
126 return: ; preds = %if.end, %entry, %if.then2
127 %retval.0 = phi i32 [ %call3, %if.then2 ], [ 0, %entry ], [ 0, %if.end ]
132 define dso_local ptr @test3(ptr nocapture %p1, i8 zeroext %p2) local_unnamed_addr {
133 ; CHECK-LABEL: test3:
134 ; CHECK: # %bb.0: # %entry
135 ; CHECK-NEXT: pushq %r14
136 ; CHECK-NEXT: .cfi_def_cfa_offset 16
137 ; CHECK-NEXT: pushq %rbx
138 ; CHECK-NEXT: .cfi_def_cfa_offset 24
139 ; CHECK-NEXT: pushq %rax
140 ; CHECK-NEXT: .cfi_def_cfa_offset 32
141 ; CHECK-NEXT: .cfi_offset %rbx, -24
142 ; CHECK-NEXT: .cfi_offset %r14, -16
143 ; CHECK-NEXT: movq (%rdi), %rbx
144 ; CHECK-NEXT: testq %rbx, %rbx
145 ; CHECK-NEXT: je .LBB2_2
146 ; CHECK-NEXT: # %bb.1: # %land.rhs
147 ; CHECK-NEXT: movq %rdi, %r14
148 ; CHECK-NEXT: movzbl %sil, %esi
149 ; CHECK-NEXT: movq %rbx, %rdi
150 ; CHECK-NEXT: callq bar@PLT
151 ; CHECK-NEXT: movq %rax, (%r14)
152 ; CHECK-NEXT: .LBB2_2: # %land.end
153 ; CHECK-NEXT: movq %rbx, %rax
154 ; CHECK-NEXT: addq $8, %rsp
155 ; CHECK-NEXT: .cfi_def_cfa_offset 24
156 ; CHECK-NEXT: popq %rbx
157 ; CHECK-NEXT: .cfi_def_cfa_offset 16
158 ; CHECK-NEXT: popq %r14
159 ; CHECK-NEXT: .cfi_def_cfa_offset 8
162 ; CHECK-32BIT-LABEL: test3:
163 ; CHECK-32BIT: # %bb.0: # %entry
164 ; CHECK-32BIT-NEXT: pushl %edi
165 ; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 8
166 ; CHECK-32BIT-NEXT: pushl %esi
167 ; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 12
168 ; CHECK-32BIT-NEXT: pushl %eax
169 ; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 16
170 ; CHECK-32BIT-NEXT: .cfi_offset %esi, -12
171 ; CHECK-32BIT-NEXT: .cfi_offset %edi, -8
172 ; CHECK-32BIT-NEXT: movl {{[0-9]+}}(%esp), %edi
173 ; CHECK-32BIT-NEXT: movl (%edi), %esi
174 ; CHECK-32BIT-NEXT: testl %esi, %esi
175 ; CHECK-32BIT-NEXT: je .LBB2_2
176 ; CHECK-32BIT-NEXT: # %bb.1: # %land.rhs
177 ; CHECK-32BIT-NEXT: subl $8, %esp
178 ; CHECK-32BIT-NEXT: .cfi_adjust_cfa_offset 8
179 ; CHECK-32BIT-NEXT: movzbl {{[0-9]+}}(%esp), %eax
180 ; CHECK-32BIT-NEXT: pushl %eax
181 ; CHECK-32BIT-NEXT: .cfi_adjust_cfa_offset 4
182 ; CHECK-32BIT-NEXT: pushl %esi
183 ; CHECK-32BIT-NEXT: .cfi_adjust_cfa_offset 4
184 ; CHECK-32BIT-NEXT: calll bar@PLT
185 ; CHECK-32BIT-NEXT: addl $16, %esp
186 ; CHECK-32BIT-NEXT: .cfi_adjust_cfa_offset -16
187 ; CHECK-32BIT-NEXT: movl %eax, (%edi)
188 ; CHECK-32BIT-NEXT: .LBB2_2: # %land.end
189 ; CHECK-32BIT-NEXT: movl %esi, %eax
190 ; CHECK-32BIT-NEXT: addl $4, %esp
191 ; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 12
192 ; CHECK-32BIT-NEXT: popl %esi
193 ; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 8
194 ; CHECK-32BIT-NEXT: popl %edi
195 ; CHECK-32BIT-NEXT: .cfi_def_cfa_offset 4
196 ; CHECK-32BIT-NEXT: retl
198 %0 = load ptr, ptr %p1, align 8, !tbaa !6
199 %tobool = icmp eq ptr %0, null
200 br i1 %tobool, label %land.end, label %land.rhs
202 land.rhs: ; preds = %entry
203 %call = tail call ptr @bar(ptr nonnull %0, i8 zeroext %p2)
204 store ptr %call, ptr %p1, align 8, !tbaa !6
207 land.end: ; preds = %entry, %land.rhs
211 declare ptr @bar(ptr, i8 zeroext) local_unnamed_addr
214 !llvm.module.flags = !{!0}
217 !0 = !{i32 1, !"wchar_size", i32 4}
218 !1 = !{!"clang version 10.0.0 (trunk 367381) (llvm/trunk 367388)"}
219 !2 = !{!3, !3, i64 0}
220 !3 = !{!"int", !4, i64 0}
221 !4 = !{!"omnipotent char", !5, i64 0}
222 !5 = !{!"Simple C/C++ TBAA"}
223 !6 = !{!7, !7, i64 0}
224 !7 = !{!"any pointer", !4, i64 0}