1 # RUN: llc -run-pass implicit-null-checks -mtriple=x86_64-apple-macosx -o - %s | FileCheck %s
3 # CHECK-NOT: FAULTING_OP
6 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7 target triple = "x86_64-unknown-linux-gnu"
9 @global = external global i8*
10 @global.1 = external global i8*
12 declare i8* @ham(i8*, i8**)
14 define void @eggs(i8* %arg) gc "statepoint-example" {
16 %tmp = call i8* undef(i8* undef, i8** undef)
17 %tmp1 = icmp eq i8* %tmp, null
18 br i1 %tmp1, label %bb2, label %bb3, !make.implicit !0
21 br i1 undef, label %bb51, label %bb59
24 %tmp4 = getelementptr inbounds i8, i8* %tmp, i64 16
25 %tmp5 = bitcast i8* %tmp4 to i64*
28 bb7: ; preds = %bb37, %bb3
29 %tmp8 = phi i64* [ %tmp5, %bb3 ], [ %tmp18, %bb37 ]
30 %tmp10 = phi i32 [ undef, %bb3 ], [ %tmp48, %bb37 ]
31 %tmp12 = phi i32 [ 0, %bb3 ], [ 6, %bb37 ]
32 %tmp13 = phi double [ 0.000000e+00, %bb3 ], [ 2.000000e+00, %bb37 ]
33 %tmp14 = zext i32 %tmp10 to i64
34 br i1 undef, label %bb26, label %bb15
37 %tmp16 = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* nonnull elementtype(void ()) @wibble, i32 0, i32 0, i32 0, i32 0) ["deopt" (i32 1, i32 0, i32 99, i32 0, i32 12, i32 0, i32 10, i32 %tmp10, i32 10, i32 0, i32 10, i32 %tmp12, i32 10, i32 undef, i32 6, float undef, i32 7, double %tmp13, i32 99, i8* null, i32 7, double undef, i32 99, i8* null, i32 13, i8* %tmp, i32 7, double undef, i32 99, i8* null, i8* undef)]
40 bb26: ; preds = %bb15, %bb7
41 %tmp18 = phi i64* [ %tmp8, %bb7 ], [ undef, %bb15 ]
43 %tmp21 = select i1 undef, i32 0, i32 %tmp20
44 %tmp22 = sext i32 %tmp21 to i64
45 %tmp23 = load i8*, i8** @global.1, align 8
46 %tmp24 = icmp eq i8* %tmp23, null
47 %tmp25 = select i1 %tmp24, i8* null, i8* undef
48 %tmp27 = load i32, i32* undef, align 4
49 %sunkaddr = mul i64 %tmp14, 8
50 %tmp2 = bitcast i64* %tmp18 to i8*
51 %sunkaddr1 = getelementptr i8, i8* %tmp2, i64 %sunkaddr
52 %tmp3 = bitcast i8* %sunkaddr1 to i64*
53 %tmp28 = load i64, i64* %tmp3, align 8
54 %tmp29 = add i64 %tmp28, 1
55 store i64 %tmp29, i64* %tmp3, align 8
56 %tmp30 = trunc i64 %tmp28 to i32
57 %tmp31 = sub i32 %tmp27, %tmp30
58 store i32 %tmp31, i32* undef, align 4
59 %tmp32 = getelementptr inbounds i8, i8* %tmp25, i64 768
60 %tmp33 = bitcast i8* %tmp32 to i64*
61 %tmp34 = load i64, i64* %tmp33, align 8
62 br i1 undef, label %bb37, label %bb35
65 %tmp36 = call i8* @ham(i8* undef, i8** nonnull @global)
68 bb37: ; preds = %bb35, %bb26
69 %tmp38 = phi i8* [ %tmp36, %bb35 ], [ undef, %bb26 ]
70 %tmp39 = getelementptr inbounds i8, i8* %tmp38, i64 760
71 %tmp40 = bitcast i8* %tmp39 to i64*
72 %tmp41 = load i64, i64* %tmp40, align 8
73 %tmp42 = icmp slt i64 %tmp34, %tmp41
74 %tmp43 = select i1 %tmp42, i64 %tmp41, i64 %tmp34
75 %tmp44 = and i64 %tmp43, 63
76 %tmp45 = ashr i64 %tmp29, %tmp44
77 %sunkaddr2 = mul i64 %tmp14, 8
78 %tmp6 = bitcast i64* %tmp18 to i8*
79 %sunkaddr3 = getelementptr i8, i8* %tmp6, i64 %sunkaddr2
80 %tmp7 = bitcast i8* %sunkaddr3 to i64*
81 store i64 %tmp45, i64* %tmp7, align 8
82 %tmp46 = sub i64 0, %tmp22
83 store i64 %tmp46, i64* undef, align 8
84 %tmp47 = add nsw i32 %tmp12, 1
85 %tmp48 = add i32 %tmp10, 1
86 %tmp49 = icmp sgt i32 %tmp48, 15140
87 br i1 %tmp49, label %bb51.loopexit, label %bb7
89 bb51.loopexit: ; preds = %bb37
90 %tmp9 = add i32 %tmp10, 1
93 bb51: ; preds = %bb51.loopexit, %bb2
94 %tmp52 = phi i32 [ %tmp47, %bb51.loopexit ], [ 0, %bb2 ]
95 %tmp53 = phi double [ 2.000000e+00, %bb51.loopexit ], [ 0.000000e+00, %bb2 ]
96 %tmp54 = phi i32 [ %tmp9, %bb51.loopexit ], [ undef, %bb2 ]
97 %tmp56 = add i32 %tmp54, 0
98 %tmp57 = call token (i64, i32, void (i32)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidi32f(i64 2882400000, i32 0, void (i32)* nonnull elementtype(void (i32)) @wobble, i32 1, i32 0, i32 -121, i32 0, i32 0) ["deopt" (i32 1, i32 0, i32 270, i32 4, i32 12, i32 0, i32 11, i64 undef, i32 99, i8* null, i32 10, i32 %tmp56, i32 6, float undef, i32 99, i8* null, i32 99, i8* null, i32 10, i32 %tmp52, i32 10, i32 undef, i32 99, i8* null, i32 7, double %tmp53, i32 99, i8* null, i32 7, double undef, i32 99, i8* null, i32 13, i8* undef, i32 99, i8* null, i32 99, i8* null, i8* undef)]
102 %tmp61 = call token (i64, i32, void (i32)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidi32f(i64 2882400000, i32 0, void (i32)* nonnull elementtype(void (i32)) @wobble, i32 1, i32 0, i32 8, i32 0, i32 0) ["deopt" (i32 1, i32 0, i32 123, i32 4, i32 12, i32 0, i32 13, i8* null, i32 99, i32 undef, i32 13, i8* null, i32 10, i32 undef, i32 99, i32 undef, i32 99, i32 undef, i32 99, i32 undef, i32 99, i8* null, i32 99, float undef, i32 99, double undef, i32 99, i8* null, i32 99, double undef, i32 99, i8* null, i32 13, i8* null, i32 99, double undef, i32 99, i8* null)]
106 declare void @wibble()
108 declare void @wobble(i32)
110 declare token @llvm.experimental.gc.statepoint.p0f_isVoidi32f(i64, i32, void (i32)*, i32, i32, ...)
112 declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
114 ; Function Attrs: nounwind
115 declare void @llvm.stackprotector(i8*, i8**) #0
117 attributes #0 = { nounwind }
124 tracksRegLiveness: true
126 - { id: 0, type: spill-slot, offset: -56, size: 8, alignment: 8, callee-saved-register: '$rbx' }
127 - { id: 1, type: spill-slot, offset: -48, size: 8, alignment: 16, callee-saved-register: '$r12' }
128 - { id: 2, type: spill-slot, offset: -40, size: 8, alignment: 8, callee-saved-register: '$r13' }
129 - { id: 3, type: spill-slot, offset: -32, size: 8, alignment: 16, callee-saved-register: '$r14' }
130 - { id: 4, type: spill-slot, offset: -24, size: 8, alignment: 8, callee-saved-register: '$r15' }
131 - { id: 5, type: spill-slot, offset: -16, size: 8, alignment: 16, callee-saved-register: '$rbp' }
133 - { id: 0, offset: -88, size: 8, alignment: 8 }
134 - { id: 1, offset: -96, size: 8, alignment: 8 }
135 - { id: 2, offset: -104, size: 8, alignment: 8 }
136 - { id: 3, offset: -64, size: 8, alignment: 8 }
137 - { id: 4, type: spill-slot, offset: -72, size: 8, alignment: 8 }
138 - { id: 5, type: spill-slot, offset: -80, size: 8, alignment: 8 }
141 value: 'double 2.000000e+00'
145 successors: %bb.1.bb2(0x00000800), %bb.3.bb3(0x7ffff800)
146 liveins: $rbp, $r15, $r14, $r13, $r12, $rbx
148 frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
149 frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp
150 frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp
151 frame-setup PUSH64r killed $r13, implicit-def $rsp, implicit $rsp
152 frame-setup PUSH64r killed $r12, implicit-def $rsp, implicit $rsp
153 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
154 $rsp = frame-setup SUB64ri8 $rsp, 56, implicit-def dead $eflags
155 CALL64r undef $rax, csr_64, implicit $rsp, implicit undef $rdi, implicit undef $rsi, implicit-def $rsp, implicit-def $rax
156 TEST64rr $rax, $rax, implicit-def $eflags
157 JCC_1 %bb.3.bb3, 5, implicit killed $eflags
160 successors: %bb.2(0x40000000), %bb.13.bb59(0x40000000)
162 $ebp = XOR32rr undef $ebp, undef $ebp, implicit-def dead $eflags
163 TEST8rr $bpl, $bpl, implicit-def $eflags
164 JCC_1 %bb.13.bb59, 4, implicit killed $eflags
167 successors: %bb.12.bb51(0x80000000)
170 $xmm0 = XORPSrr undef $xmm0, undef $xmm0
171 $ebx = IMPLICIT_DEF implicit-def $rbx
175 successors: %bb.4.bb7(0x80000000)
178 MOV64mr $rsp, 1, $noreg, 32, $noreg, $rax :: (store (s64) into %stack.5)
179 $r12 = MOV64rr killed $rax
180 $r12 = ADD64ri8 killed $r12, 16, implicit-def dead $eflags
181 $xmm0 = XORPSrr undef $xmm0, undef $xmm0
182 $esi = XOR32rr undef $esi, undef $esi, implicit-def dead $eflags
183 $rax = MOV64ri %const.0
184 $xmm1 = MOVSDrm_alt killed $rax, 1, $noreg, 0, $noreg :: (load (s64) from constant-pool)
185 MOVSDmr $rsp, 1, $noreg, 40, $noreg, killed $xmm1 :: (store (s64) into %stack.4)
187 $ecx = XOR32rr undef $ecx, undef $ecx, implicit-def dead $eflags
190 successors: %bb.6.bb26(0x40000000), %bb.5.bb15(0x40000000)
191 liveins: $eax, $ecx, $esi, $r12, $xmm0
193 $ebp = MOV32rr killed $ecx
194 $ebx = MOV32rr killed $eax, implicit-def $rbx
195 $r14d = MOV32rr $ebx, implicit-def $r14
196 TEST8rr $sil, $sil, implicit-def $eflags
197 JCC_1 %bb.6.bb26, 5, implicit $eflags
200 successors: %bb.6.bb26(0x80000000)
201 liveins: $ebp, $rbx, $r14, $xmm0
203 MOV32mr $rsp, 1, $noreg, 24, $noreg, $ebx :: (store (s32) into %stack.0, align 8)
204 MOV32mr $rsp, 1, $noreg, 16, $noreg, $ebp :: (store (s32) into %stack.1, align 8)
205 MOVSDmr $rsp, 1, $noreg, 8, $noreg, killed $xmm0 :: (store (s64) into %stack.2)
206 $rax = MOV64rm $rsp, 1, $noreg, 32, $noreg :: (load (s64) from %stack.5)
207 MOV64mr $rsp, 1, $noreg, 48, $noreg, killed $rax :: (store (s64) into %stack.3)
208 $rax = MOV64ri @wibble
209 STATEPOINT 2882400000, 0, 0, killed $rax, 2, 0, 2, 0, 2, 30, 2, 1, 2, 0, 2, 99, 2, 0, 2, 12, 2, 0, 2, 10, 1, 8, $rsp, 24, 2, 10, 2, 0, 2, 10, 1, 8, $rsp, 16, 2, 10, 2, 4278124286, 2, 6, 2, 4278124286, 2, 7, 1, 8, $rsp, 8, 2, 99, 2, 0, 2, 7, 2, 4278124286, 2, 99, 2, 0, 2, 13, 1, 8, $rsp, 48, 2, 7, 2, 4278124286, 2, 99, 2, 0, 2, 0, 2, 0, 2, 0, csr_64, implicit-def $rsp :: (volatile load (s64) from %stack.0), (volatile load (s64) from %stack.1), (volatile load (s64) from %stack.2), (volatile load (s64) from %stack.3)
210 $esi = XOR32rr undef $esi, undef $esi, implicit-def dead $eflags
214 successors: %bb.8.bb37(0x40000000), %bb.7.bb35(0x40000000)
215 liveins: $ebp, $esi, $rbx, $r12, $r14
217 $rax = MOV64ri @global.1
218 $rax = MOV64rm killed $rax, 1, $noreg, 0, $noreg :: (dereferenceable load (s64) from @global.1)
219 TEST64rr $rax, $rax, implicit-def $eflags
220 $rax = CMOV64rr undef $rax, killed $rax, 4, implicit killed $eflags
221 $ecx = MOV32rm undef $rax, 1, $noreg, 0, $noreg :: (load (s32) from `i32* undef`)
222 $rdx = MOV64rm $r12, 8, $r14, 0, $noreg :: (load (s64) from %ir.tmp3)
223 $r15 = LEA64r $rdx, 1, $noreg, 1, _
224 MOV64mr $r12, 8, $r14, 0, $noreg, $r15 :: (store (s64) into %ir.tmp3)
225 $ecx = SUB32rr killed $ecx, $edx, implicit-def dead $eflags, implicit killed $rdx
226 MOV32mr undef $rax, 1, $noreg, 0, $noreg, killed $ecx :: (store (s32) into `i32* undef`)
227 $r13 = MOV64rm killed $rax, 1, $noreg, 768, $noreg :: (load (s64) from %ir.tmp33)
228 TEST8rr $sil, $sil, implicit-def $eflags
230 JCC_1 %bb.8.bb37, 5, implicit $eflags
233 successors: %bb.8.bb37(0x80000000)
234 liveins: $ebp, $rbx, $r12, $r13, $r14, $r15
236 $rsi = MOV64ri @global
238 CALL64r killed $rax, csr_64, implicit $rsp, implicit undef $rdi, implicit $rsi, implicit-def $rsp, implicit-def $rax
239 $esi = XOR32rr undef $esi, undef $esi, implicit-def dead $eflags
242 successors: %bb.9.bb37(0x40000000), %bb.10.bb37(0x40000000)
243 liveins: $ebp, $esi, $rax, $rbx, $r12, $r13, $r14, $r15
245 $rcx = MOV64rm killed $rax, 1, $noreg, 760, $noreg :: (load (s64) from %ir.tmp40)
246 CMP64rr $r13, $rcx, implicit-def $eflags
247 JCC_1 %bb.10.bb37, 12, implicit $eflags
250 successors: %bb.10.bb37(0x80000000)
251 liveins: $ebp, $esi, $rbx, $r12, $r13, $r14, $r15
253 $cl = MOV8rr $r13b, implicit killed $r13, implicit-def $rcx
256 successors: %bb.11.bb51.loopexit(0x00000800), %bb.4.bb7(0x7ffff800)
257 liveins: $ebp, $esi, $rbx, $rcx, $r12, $r14, $r15
259 $cl = KILL $cl, implicit killed $rcx
260 $r15 = SAR64rCL killed $r15, implicit-def dead $eflags, implicit $cl
261 MOV64mr $r12, 8, killed $r14, 0, $noreg, killed $r15 :: (store (s64) into %ir.tmp7)
262 MOV64mi32 undef $rax, 1, $noreg, 0, $noreg, 0 :: (store (s64) into `i64* undef`)
263 $eax = LEA64_32r $rbx, 1, $noreg, 1, _
265 CMP32ri $eax, 15141, implicit-def $eflags
266 $xmm0 = MOVSDrm_alt $rsp, 1, $noreg, 40, $noreg :: (load (s64) from %stack.4)
267 JCC_1 %bb.4.bb7, 12, implicit $eflags
270 successors: %bb.12.bb51(0x80000000)
273 $ebp = INC32r killed $ebp, implicit-def dead $eflags
274 $ebx = INC32r $ebx, implicit-def dead $eflags, implicit killed $rbx, implicit-def $rbx
275 $rax = MOV64ri %const.0
276 $xmm0 = MOVSDrm_alt killed $rax, 1, $noreg, 0, $noreg :: (load (s64) from constant-pool)
279 liveins: $ebp, $rbx, $xmm0
281 MOV32mr $rsp, 1, $noreg, 24, $noreg, $ebx, implicit killed $rbx :: (store (s32) into %stack.0, align 8)
282 MOV32mr $rsp, 1, $noreg, 16, $noreg, killed $ebp :: (store (s32) into %stack.1, align 8)
283 MOVSDmr $rsp, 1, $noreg, 8, $noreg, killed $xmm0 :: (store (s64) into %stack.2)
284 $rax = MOV64ri @wobble
286 STATEPOINT 2882400000, 0, 1, killed $rax, $edi, 2, 0, 2, 0, 2, 38, 2, 1, 2, 0, 2, 270, 2, 4, 2, 12, 2, 0, 2, 11, 2, 4278124286, 2, 99, 2, 0, 2, 10, 1, 8, $rsp, 24, 2, 6, 2, 4278124286, 2, 99, 2, 0, 2, 99, 2, 0, 2, 10, 1, 8, $rsp, 16, 2, 10, 2, 4278124286, 2, 99, 2, 0, 2, 7, 1, 8, $rsp, 8, 2, 99, 2, 0, 2, 7, 2, 4278124286, 2, 99, 2, 0, 2, 13, 2, 4278124286, 2, 99, 2, 0, 2, 99, 2, 0, 2, 0, 2, 0, 2, 0, csr_64, implicit-def $rsp :: (volatile load (s64) from %stack.0), (volatile load (s64) from %stack.1), (volatile load (s64) from %stack.2)
289 $rax = MOV64ri @wobble
291 STATEPOINT 2882400000, 0, 1, killed $rax, $edi, 2, 0, 2, 0, 2, 38, 2, 1, 2, 0, 2, 123, 2, 4, 2, 12, 2, 0, 2, 13, 2, 0, 2, 99, 2, 4278124286, 2, 13, 2, 0, 2, 10, 2, 4278124286, 2, 99, 2, 4278124286, 2, 99, 2, 4278124286, 2, 99, 2, 4278124286, 2, 99, 2, 0, 2, 99, 2, 4278124286, 2, 99, 2, 4278124286, 2, 99, 2, 0, 2, 99, 2, 4278124286, 2, 99, 2, 0, 2, 13, 2, 0, 2, 99, 2, 4278124286, 2, 99, 2, 0, 2, 0, 2, 0, 2, 0, csr_64, implicit-def $rsp