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