1 # RUN: llc --run-pass=register-coalescer -o - %s | FileCheck %s
3 # Coalescing variables across a setjmp call can add a undefined
4 # variable value when longjmp if such variables are spilled and
5 # altered between the setjmp and longjmp.
7 # This file tests a very particular case for
8 # no coalescing stack pointers across the
10 # CHECK: %[[R1:[0-9]+]]:gpr = ADDri %stack.0.P0, 0, 14
13 # CHECK: %[[R2:[0-9]+]]:gpr = nuw ADDri %[[R1]], 8, 14
16 # Not changed between setjmp and bar(longjmp)
17 # CHECK-NOT: %{{[0-9]+}}:dpr, %[[R2]]:gpr = VLD1d32wb_fixed %[[R2]], 0,
18 # CHECK: BL @_Z3barPx3S37{{.*}}
19 # CHECK: %[[R3:[0-9]+]]:gpr = COPY %[[R2]]
22 # CHECK-NOT: VLD1d32wb_fixed %[[R2]]
23 # CHECK: VLD1d32wb_fixed %[[R3]]
25 target triple = "armv8-arm-none-eabi"
27 %"class.std::__1::ios_base::Init" = type { i8 }
28 %struct.S37 = type <{ i8, [7 x i8], %struct.S38, [2 x %"class.std::__1::complex"], float, [4 x i8], i64, i32, [4 x i8] }>
29 %struct.S38 = type { double, i8 }
30 %"class.std::__1::complex" = type { double, double }
31 %struct.S18 = type <{ i32, [4 x i8], double, double, double, i32, [4 x i8], %struct.S23, i32, [4 x i8] }>
32 %struct.S23 = type { [2 x double], half }
35 %P0 = alloca %struct.S37, align 8
36 %0 = bitcast %struct.S37* %P0 to %struct.S18*
37 %jb1 = alloca [20 x i64], align 8
38 %P1 = alloca %struct.S18, align 8
39 %jb2 = alloca [20 x i64], align 8
40 %1 = bitcast %struct.S37* %P0 to i8*
41 %M2.i = getelementptr inbounds %struct.S37, %struct.S37* %P0, i32 0, i32 2
42 %2 = bitcast %struct.S38* %M2.i to i8*
43 call void @llvm.memset.p0i8.i64(i8* nonnull align 8 dereferenceable(48) %2, i8 0, i64 48, i1 false)
44 %M6.i = getelementptr inbounds %struct.S37, %struct.S37* %P0, i32 0, i32 7
45 store i32 0, i32* %M6.i, align 8
46 %3 = bitcast [20 x i64]* %jb1 to i8*
47 %arraydecay1 = bitcast [20 x i64]* %jb1 to i64*
48 %call1 = call i32 @setjmp(i64* nonnull %arraydecay1)
49 %tobool = icmp eq i32 %call1, 0
50 br i1 %tobool, label %if.then, label %if.end
51 if.then: ; preds = %entry
52 %4 = bitcast [20 x i64]* %jb1 to i64*
53 call void (i64*, %struct.S37*, ...) @_Z3barPx3S37z(i64* nonnull %4, %struct.S37* nonnull byval(%struct.S37) align 8 %P0)
55 if.end: ; preds = %entry
56 %5 = bitcast [20 x i64]* %jb1 to i8*
57 %6 = bitcast %struct.S37* %P0 to i8*
58 call void asm sideeffect "", "~{r0},~{r1},~{r2},~{r3},~{r4},~{r5},~{r6},~{r7},~{r8},~{r9},~{r10},~{r11},~{r12},~{sp},~{lr}"()
59 %7 = bitcast %struct.S18* %0 to i8*
60 %BM0.i = getelementptr inbounds %struct.S18, %struct.S18* %0, i32 0, i32 2
61 store double 0.000000e+00, double* %BM0.i, align 8
62 %M0.i = getelementptr inbounds %struct.S18, %struct.S18* %0, i32 0, i32 5
63 store i32 42, i32* %M0.i, align 8
64 %M3.i = getelementptr inbounds %struct.S18, %struct.S18* %0, i32 0, i32 7
65 %8 = bitcast %struct.S23* %M3.i to i8*
66 call void @llvm.memset.p0i8.i64(i8* nonnull align 8 dereferenceable(28) %8, i8 0, i64 28, i1 false)
67 %9 = bitcast [20 x i64]* %jb1 to i8*
68 %arraydecay42 = bitcast [20 x i64]* %jb1 to i64*
69 %call5 = call i32 @setjmp(i64* nonnull %arraydecay42)
70 %tobool6 = icmp eq i32 %call5, 0
71 br i1 %tobool6, label %if.then7, label %if.end10
72 if.then7: ; preds = %if.end
73 %10 = bitcast [20 x i64]* %jb1 to i64*
74 call void (i64*, %struct.S18*, ...) @_Z3fooPx3S18z(i64* nonnull %10, %struct.S18* nonnull byval(%struct.S18) align 8 %0)
76 if.end10: ; preds = %if.end
77 %11 = bitcast [20 x i64]* %jb1 to i8*
78 %12 = bitcast %struct.S18* %0 to i8*
81 declare i32 @setjmp(i64*)
82 declare void @_Z3barPx3S37z(i64*, %struct.S37* byval(%struct.S37) align 8, ...)
83 declare void @_Z3fooPx3S18z(i64*, %struct.S18* byval(%struct.S18) align 8, ...)
84 declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg)
88 exposesReturnsTwice: true
90 - { id: 0, name: P0, size: 80, alignment: 8, local-offset: -80 }
91 - { id: 1, name: jb1, size: 160, alignment: 8, local-offset: -240 }
92 machineFunctionInfo: {}
95 successors: %bb.1(0x00000001), %bb.4(0x7fffffff)
96 %0:qpr = VMOVv4i32 0, 14, $noreg
97 %1:gpr = ADDri %stack.0.P0, 0, 14, $noreg, $noreg
98 %2:gpr = ADDri %1, 40, 14, $noreg, $noreg
99 VST1q64 %2, 0, %0, 14, $noreg
100 %3:gpr = ADDri %1, 24, 14, $noreg, $noreg
101 VST1q64 killed %3, 0, %0, 14, $noreg
102 %4:gpr = nuw ADDri %1, 8, 14, $noreg, $noreg
103 VST1q64 %4, 0, %0, 14, $noreg
104 %5:gpr = MOVi 0, 14, $noreg, $noreg
105 STRi12 %5, %stack.0.P0, 72, 14, $noreg
106 ADJCALLSTACKDOWN 0, 0, 14, $noreg, implicit-def dead $sp, implicit $sp
107 %6:gpr = ADDri %stack.1.jb1, 0, 14, $noreg, $noreg
109 BL @setjmp, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $r0, implicit-def $sp, implicit-def $r0
110 ADJCALLSTACKUP 0, 0, 14, $noreg, implicit-def dead $sp, implicit $sp
111 %7:gpr = COPY killed $r0
112 CMPri killed %7, 0, 14, $noreg, implicit-def $cpsr
113 Bcc %bb.4, 1, killed $cpsr
116 ADJCALLSTACKDOWN 72, 0, 14, $noreg, implicit-def dead $sp, implicit $sp
117 %24:gpr = LDRi12 %stack.0.P0, 0, 14, $noreg
118 %25:gpr = LDRi12 %stack.0.P0, 4, 14, $noreg
120 %29:gpr = MOVi16 72, 14, $noreg
121 %61:gpr = COPY killed %29
122 %62:gpr = COPY killed %4
123 %63:gpr = COPY killed %27
124 bb.2 (call-frame-size 72):
125 %35:gpr = COPY killed %63
126 %33:gpr = COPY killed %62
127 %31:gpr = COPY killed %61
128 %32:gpr = COPY killed %33
129 %36:dpr, %32:gpr = VLD1d32wb_fixed %32, 0, 14, $noreg
130 %34:gpr = COPY killed %35
131 %34:gpr = VST1d32wb_fixed %34, 0, killed %36, 14, $noreg
132 %30:gpr = SUBri killed %31, 8, 14, $noreg, def $cpsr
133 %61:gpr = COPY killed %30
134 %62:gpr = COPY killed %32
135 %63:gpr = COPY killed %34
136 Bcc %bb.2, 1, killed $cpsr
137 bb.3 (call-frame-size 72):
139 %28:gpr = ADDri %stack.1.jb1, 0, 14, $noreg, $noreg
140 $r0 = COPY killed %28
141 $r2 = COPY killed %24
142 $r3 = COPY killed %25
143 BL @_Z3barPx3S37z, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $r0, implicit killed $r2, implicit killed $r3, implicit-def $sp
144 ADJCALLSTACKUP 72, 0, 14, $noreg, implicit-def dead $sp, implicit $sp
146 successors: %bb.5(0x00000001), %bb.6(0x7fffffff)
147 INLINEASM &"", 1, 12, implicit-def dead early-clobber $r0, 12, implicit-def dead early-clobber $r1, 12, implicit-def dead early-clobber $r2, 12, implicit-def dead early-clobber $r3, 12, implicit-def dead early-clobber $r4, 12, implicit-def dead early-clobber $r5, 12, implicit-def dead early-clobber $r6, 12, implicit-def dead early-clobber $r7, 12, implicit-def dead early-clobber $r8, 12, implicit-def dead early-clobber $r9, 12, implicit-def dead early-clobber $r10, 12, implicit-def dead early-clobber $r11, 12, implicit-def dead early-clobber $r12, 12, implicit-def early-clobber $sp, 12, implicit-def dead early-clobber $lr
148 VST1q64 killed %2, 0, %0, 14, $noreg
149 %11:gpr = ADDri killed %1, 52, 14, $noreg, $noreg
150 VST1q32 killed %11, 0, killed %0, 14, $noreg
151 STRi12 %5, %stack.0.P0, 12, 14, $noreg
152 STRi12 killed %5, %stack.0.P0, 8, 14, $noreg
153 %13:gpr = MOVi 42, 14, $noreg, $noreg
154 STRi12 killed %13, %stack.0.P0, 32, 14, $noreg
155 ADJCALLSTACKDOWN 0, 0, 14, $noreg, implicit-def dead $sp, implicit $sp
156 %14:gpr = ADDri %stack.1.jb1, 0, 14, $noreg, $noreg
157 $r0 = COPY killed %14
158 BL @setjmp, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $r0, implicit-def $sp, implicit-def $r0
159 ADJCALLSTACKUP 0, 0, 14, $noreg, implicit-def dead $sp, implicit $sp
160 %15:gpr = COPY killed $r0
161 CMPri killed %15, 0, 14, $noreg, implicit-def $cpsr
162 Bcc %bb.6, 1, killed $cpsr
166 ADJCALLSTACKDOWN 64, 0, 14, $noreg, implicit-def dead $sp, implicit $sp
167 %18:gpr = LDRi12 %stack.0.P0, 0, 14, $noreg
168 %19:gpr = LDRi12 %stack.0.P0, 4, 14, $noreg
170 %37:gpr = COPY killed %4
171 %39:dpr, %37:gpr = VLD1d32wb_fixed %37, 0, 14, $noreg
172 %38:gpr = COPY killed %21
173 %38:gpr = VST1d32wb_fixed %38, 0, killed %39, 14, $noreg
174 %40:gpr = COPY killed %37
175 %42:dpr, %40:gpr = VLD1d32wb_fixed %40, 0, 14, $noreg
176 %41:gpr = COPY killed %38
177 %41:gpr = VST1d32wb_fixed %41, 0, killed %42, 14, $noreg
178 %43:gpr = COPY killed %40
179 %45:dpr, %43:gpr = VLD1d32wb_fixed %43, 0, 14, $noreg
180 %44:gpr = COPY killed %41
181 %44:gpr = VST1d32wb_fixed %44, 0, killed %45, 14, $noreg
182 %46:gpr = COPY killed %43
183 %48:dpr, %46:gpr = VLD1d32wb_fixed %46, 0, 14, $noreg
184 %47:gpr = COPY killed %44
185 %47:gpr = VST1d32wb_fixed %47, 0, killed %48, 14, $noreg
186 %49:gpr = COPY killed %46
187 %51:dpr, %49:gpr = VLD1d32wb_fixed %49, 0, 14, $noreg
188 %50:gpr = COPY killed %47
189 %50:gpr = VST1d32wb_fixed %50, 0, killed %51, 14, $noreg
190 %52:gpr = COPY killed %49
191 %54:dpr, %52:gpr = VLD1d32wb_fixed %52, 0, 14, $noreg
192 %53:gpr = COPY killed %50
193 %53:gpr = VST1d32wb_fixed %53, 0, killed %54, 14, $noreg
194 %55:gpr = COPY killed %52
195 %57:dpr, %55:gpr = VLD1d32wb_fixed %55, 0, 14, $noreg
196 %56:gpr = COPY killed %53
197 %56:gpr = VST1d32wb_fixed %56, 0, killed %57, 14, $noreg
198 %58:gpr = COPY killed %55
199 %60:dpr, dead %58:gpr = VLD1d32wb_fixed %58, 0, 14, $noreg
200 %59:gpr = COPY killed %56
201 dead %59:gpr = VST1d32wb_fixed %59, 0, killed %60, 14, $noreg
202 %22:gpr = ADDri %stack.1.jb1, 0, 14, $noreg, $noreg
203 $r0 = COPY killed %22
204 $r2 = COPY killed %18
205 $r3 = COPY killed %19
206 BL @_Z3fooPx3S18z, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $r0, implicit killed $r2, implicit killed $r3, implicit-def $sp
207 ADJCALLSTACKUP 64, 0, 14, $noreg, implicit-def dead $sp, implicit $sp
209 %16:gpr = MOVi 0, 14, $noreg, $noreg
210 $r0 = COPY killed %16
211 BX_RET 14, $noreg, implicit killed $r0