1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2 ; RUN: llc < %s -mtriple=thumbv6m | FileCheck %s
3 ; RUN: llc < %s -mtriple=thumbv6m -mattr=+execute-only | FileCheck %s -check-prefix=V6M
4 ; RUN: llc < %s -mtriple=thumbv8m.base -mattr=+execute-only | FileCheck %s -check-prefix=V8MBASE
6 define dso_local i32 @main() #0 {
8 ; CHECK: @ %bb.0: @ %entry
9 ; CHECK-NEXT: push {r7, lr}
10 ; CHECK-NEXT: sub sp, #24
11 ; CHECK-NEXT: movs r0, #0
12 ; CHECK-NEXT: str r0, [sp, #4]
13 ; CHECK-NEXT: ldr r0, .LCPI0_0
14 ; CHECK-NEXT: ldr r0, [r0]
15 ; CHECK-NEXT: str r0, [sp, #20]
16 ; CHECK-NEXT: add r0, sp, #8
17 ; CHECK-NEXT: ldrb r0, [r0]
18 ; CHECK-NEXT: ldr r1, [sp, #20]
19 ; CHECK-NEXT: ldr r2, .LCPI0_0
20 ; CHECK-NEXT: ldr r2, [r2]
21 ; CHECK-NEXT: cmp r2, r1
22 ; CHECK-NEXT: bne .LBB0_2
23 ; CHECK-NEXT: @ %bb.1: @ %entry
24 ; CHECK-NEXT: add sp, #24
25 ; CHECK-NEXT: pop {r7, pc}
26 ; CHECK-NEXT: .LBB0_2: @ %entry
27 ; CHECK-NEXT: bl __stack_chk_fail
28 ; CHECK-NEXT: .p2align 2
29 ; CHECK-NEXT: @ %bb.3:
30 ; CHECK-NEXT: .LCPI0_0:
31 ; CHECK-NEXT: .long __stack_chk_guard
34 ; V6M: @ %bb.0: @ %entry
35 ; V6M-NEXT: push {r7, lr}
37 ; V6M-NEXT: movs r0, #0
38 ; V6M-NEXT: str r0, [sp, #
39 ; V6M-NEXT: mrs r12, apsr
40 ; V6M-NEXT: movs r0, :upper8_15:__stack_chk_guard
41 ; V6M-NEXT: lsls r0, r0, #8
42 ; V6M-NEXT: adds r0, :upper0_7:__stack_chk_guard
43 ; V6M-NEXT: lsls r0, r0, #8
44 ; V6M-NEXT: adds r0, :lower8_15:__stack_chk_guard
45 ; V6M-NEXT: lsls r0, r0, #8
46 ; V6M-NEXT: adds r0, :lower0_7:__stack_chk_guard
47 ; V6M-NEXT: msr apsr, r12
48 ; V6M-NEXT: ldr r0, [r0]
49 ; V6M-NEXT: str r0, [sp, #
50 ; V6M-NEXT: add r0, sp, #
51 ; V6M-NEXT: ldrb r0, [r0]
52 ; V6M-NEXT: ldr r1, [sp, #
53 ; V6M-NEXT: mrs r12, apsr
54 ; V6M-NEXT: movs r2, :upper8_15:__stack_chk_guard
55 ; V6M-NEXT: lsls r2, r2, #8
56 ; V6M-NEXT: adds r2, :upper0_7:__stack_chk_guard
57 ; V6M-NEXT: lsls r2, r2, #8
58 ; V6M-NEXT: adds r2, :lower8_15:__stack_chk_guard
59 ; V6M-NEXT: lsls r2, r2, #8
60 ; V6M-NEXT: adds r2, :lower0_7:__stack_chk_guard
61 ; V6M-NEXT: msr apsr, r12
62 ; V6M-NEXT: ldr r2, [r2]
63 ; V6M-NEXT: cmp r2, r1
64 ; V6M-NEXT: bne .LBB0_2
65 ; V6M-NEXT: @ %bb.1: @ %entry
67 ; V6M-NEXT: pop {r7, pc}
68 ; V6M-NEXT: .LBB0_2: @ %entry
69 ; V6M-NEXT: bl __stack_chk_fail
71 ; V8MBASE-LABEL: main:
72 ; V8MBASE: @ %bb.0: @ %entry
73 ; V8MBASE-NEXT: push {r7, lr}
74 ; V8MBASE-NEXT: sub sp, #24
75 ; V8MBASE-NEXT: movs r0, #0
76 ; V8MBASE-NEXT: str r0, [sp, #4]
77 ; V8MBASE-NEXT: movw r0, :lower16:__stack_chk_guard
78 ; V8MBASE-NEXT: movt r0, :upper16:__stack_chk_guard
79 ; V8MBASE-NEXT: ldr r0, [r0]
80 ; V8MBASE-NEXT: str r0, [sp, #20]
81 ; V8MBASE-NEXT: add r0, sp, #8
82 ; V8MBASE-NEXT: ldrb r0, [r0]
83 ; V8MBASE-NEXT: ldr r1, [sp, #20]
84 ; V8MBASE-NEXT: movw r2, :lower16:__stack_chk_guard
85 ; V8MBASE-NEXT: movt r2, :upper16:__stack_chk_guard
86 ; V8MBASE-NEXT: ldr r2, [r2]
87 ; V8MBASE-NEXT: cmp r2, r1
88 ; V8MBASE-NEXT: bne .LBB0_2
89 ; V8MBASE-NEXT: @ %bb.1: @ %entry
90 ; V8MBASE-NEXT: add sp, #24
91 ; V8MBASE-NEXT: pop {r7, pc}
92 ; V8MBASE-NEXT: .LBB0_2: @ %entry
93 ; V8MBASE-NEXT: bl __stack_chk_fail
95 %retval = alloca i32, align 4
96 %buffer = alloca [9 x i8], align 1
97 store i32 0, ptr %retval, align 4
98 %arrayidx = getelementptr inbounds [9 x i8], ptr %buffer, i32 0, i32 0
99 %0 = load i8, ptr %arrayidx, align 1
100 %conv = zext i8 %0 to i32
104 @aa = hidden local_unnamed_addr global i32 0, align 4
105 @bb = hidden local_unnamed_addr global i64 0, align 8
107 define dso_local i64 @cc() local_unnamed_addr #1 {
109 ; V6M: @ %bb.0: @ %entry
110 ; V6M-NEXT: push {r4, r5, r7, lr}
111 ; V6M-NEXT: sub sp, #8
112 ; V6M-NEXT: movs r0, #1
113 ; V6M-NEXT: lsls r3, r0, #31
114 ; V6M-NEXT: movs r0, :upper8_15:aa
115 ; V6M-NEXT: lsls r0, r0, #8
116 ; V6M-NEXT: adds r0, :upper0_7:aa
117 ; V6M-NEXT: lsls r0, r0, #8
118 ; V6M-NEXT: adds r0, :lower8_15:aa
119 ; V6M-NEXT: lsls r0, r0, #8
120 ; V6M-NEXT: adds r0, :lower0_7:aa
121 ; V6M-NEXT: ldr r2, [r0]
122 ; V6M-NEXT: asrs r4, r2, #31
123 ; V6M-NEXT: eors r3, r4
124 ; V6M-NEXT: movs r0, :upper8_15:bb
125 ; V6M-NEXT: lsls r0, r0, #8
126 ; V6M-NEXT: adds r0, :upper0_7:bb
127 ; V6M-NEXT: lsls r0, r0, #8
128 ; V6M-NEXT: adds r0, :lower8_15:bb
129 ; V6M-NEXT: lsls r0, r0, #8
130 ; V6M-NEXT: adds r0, :lower0_7:bb
131 ; V6M-NEXT: ldm r0!, {r1, r5}
132 ; V6M-NEXT: subs r0, r2, r1
133 ; V6M-NEXT: sbcs r3, r5
134 ; V6M-NEXT: subs r0, r2, r1
135 ; V6M-NEXT: mrs r12, apsr
136 ; V6M-NEXT: movs r1, :upper8_15:__stack_chk_guard
137 ; V6M-NEXT: lsls r1, r1, #8
138 ; V6M-NEXT: adds r1, :upper0_7:__stack_chk_guard
139 ; V6M-NEXT: lsls r1, r1, #8
140 ; V6M-NEXT: adds r1, :lower8_15:__stack_chk_guard
141 ; V6M-NEXT: lsls r1, r1, #8
142 ; V6M-NEXT: adds r1, :lower0_7:__stack_chk_guard
143 ; V6M-NEXT: msr apsr, r12
144 ; V6M-NEXT: ldr r1, [r1]
145 ; V6M-NEXT: str r1, [sp, #4]
146 ; V6M-NEXT: mov r1, r4
147 ; V6M-NEXT: sbcs r1, r5
148 ; V6M-NEXT: ands r3, r4
149 ; V6M-NEXT: ands r2, r0
150 ; V6M-NEXT: mov r4, r2
151 ; V6M-NEXT: orrs r4, r3
152 ; V6M-NEXT: beq .LBB1_2
153 ; V6M-NEXT: @ %bb.1: @ %entry
154 ; V6M-NEXT: mov r1, r3
155 ; V6M-NEXT: .LBB1_2: @ %entry
156 ; V6M-NEXT: cmp r4, #0
157 ; V6M-NEXT: beq .LBB1_4
158 ; V6M-NEXT: @ %bb.3: @ %entry
159 ; V6M-NEXT: mov r0, r2
160 ; V6M-NEXT: .LBB1_4: @ %entry
161 ; V6M-NEXT: ldr r2, [sp, #4]
162 ; V6M-NEXT: mrs r12, apsr
163 ; V6M-NEXT: movs r3, :upper8_15:__stack_chk_guard
164 ; V6M-NEXT: lsls r3, r3, #8
165 ; V6M-NEXT: adds r3, :upper0_7:__stack_chk_guard
166 ; V6M-NEXT: lsls r3, r3, #8
167 ; V6M-NEXT: adds r3, :lower8_15:__stack_chk_guard
168 ; V6M-NEXT: lsls r3, r3, #8
169 ; V6M-NEXT: adds r3, :lower0_7:__stack_chk_guard
170 ; V6M-NEXT: msr apsr, r12
171 ; V6M-NEXT: ldr r3, [r3]
172 ; V6M-NEXT: cmp r3, r2
173 ; V6M-NEXT: bne .LBB1_6
174 ; V6M-NEXT: @ %bb.5: @ %entry
175 ; V6M-NEXT: add sp, #8
176 ; V6M-NEXT: pop {r4, r5, r7, pc}
177 ; V6M-NEXT: .LBB1_6: @ %entry
178 ; V6M-NEXT: bl __stack_chk_fail
181 %0 = load i32, ptr @aa, align 4
182 %conv = sext i32 %0 to i64
183 %xor = xor i64 %conv, -9223372036854775808
184 %1 = load i64, ptr @bb, align 8
185 %sub = sub nsw i64 %xor, %1
186 %and = and i64 %sub, %conv
187 %tobool.not = icmp eq i64 %and, 0
188 %sub3 = sub nsw i64 %conv, %1
189 %spec.select = select i1 %tobool.not, i64 %sub3, i64 %and
193 attributes #0 = { ssp "stack-protector-buffer-size"="8" }
194 attributes #1 = { sspreq }