1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; Test basic address sanitizer instrumentation.
3 ; Generic code is covered by ../basic.ll, only the x86_64 specific code is
6 ; RUN: opt < %s -passes=hwasan -hwasan-recover=0 -S | FileCheck %s --check-prefixes=ABORT
7 ; RUN: opt < %s -passes=hwasan -hwasan-recover=1 -S | FileCheck %s --check-prefixes=RECOVER
8 ; RUN: opt < %s -passes=hwasan -hwasan-recover=0 -hwasan-instrument-with-calls=0 -S | FileCheck %s --check-prefixes=ABORT-INLINE
9 ; RUN: opt < %s -passes=hwasan -hwasan-recover=1 -hwasan-instrument-with-calls=0 -S | FileCheck %s --check-prefixes=RECOVER-INLINE
11 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
12 target triple = "x86_64-unknown-linux-gnu"
14 define i8 @test_load8(ptr %a) sanitize_hwaddress {
15 ; ABORT-LABEL: define i8 @test_load8
16 ; ABORT-SAME: (ptr [[A:%.*]]) #[[ATTR0:[0-9]+]] {
18 ; ABORT-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
19 ; ABORT-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
20 ; ABORT-NEXT: call void @__hwasan_load1(i64 [[TMP0]])
21 ; ABORT-NEXT: [[B:%.*]] = load i8, ptr [[A]], align 4
22 ; ABORT-NEXT: ret i8 [[B]]
24 ; RECOVER-LABEL: define i8 @test_load8
25 ; RECOVER-SAME: (ptr [[A:%.*]]) #[[ATTR0:[0-9]+]] {
26 ; RECOVER-NEXT: entry:
27 ; RECOVER-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
28 ; RECOVER-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
29 ; RECOVER-NEXT: call void @__hwasan_load1_noabort(i64 [[TMP0]])
30 ; RECOVER-NEXT: [[B:%.*]] = load i8, ptr [[A]], align 4
31 ; RECOVER-NEXT: ret i8 [[B]]
33 ; ABORT-INLINE-LABEL: define i8 @test_load8
34 ; ABORT-INLINE-SAME: (ptr [[A:%.*]]) #[[ATTR0:[0-9]+]] {
35 ; ABORT-INLINE-NEXT: entry:
36 ; ABORT-INLINE-NEXT: [[TMP0:%.*]] = load i64, ptr @__hwasan_tls, align 8
37 ; ABORT-INLINE-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], -9079256848778919937
38 ; ABORT-INLINE-NEXT: [[TMP2:%.*]] = or i64 [[TMP1]], 4294967295
39 ; ABORT-INLINE-NEXT: [[HWASAN_SHADOW:%.*]] = add i64 [[TMP2]], 1
40 ; ABORT-INLINE-NEXT: [[TMP3:%.*]] = inttoptr i64 [[HWASAN_SHADOW]] to ptr
41 ; ABORT-INLINE-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[A]] to i64
42 ; ABORT-INLINE-NEXT: [[TMP5:%.*]] = lshr i64 [[TMP4]], 57
43 ; ABORT-INLINE-NEXT: [[TMP6:%.*]] = trunc i64 [[TMP5]] to i8
44 ; ABORT-INLINE-NEXT: [[TMP7:%.*]] = and i64 [[TMP4]], -9079256848778919937
45 ; ABORT-INLINE-NEXT: [[TMP8:%.*]] = lshr i64 [[TMP7]], 4
46 ; ABORT-INLINE-NEXT: [[TMP9:%.*]] = getelementptr i8, ptr [[TMP3]], i64 [[TMP8]]
47 ; ABORT-INLINE-NEXT: [[TMP10:%.*]] = load i8, ptr [[TMP9]], align 1
48 ; ABORT-INLINE-NEXT: [[TMP11:%.*]] = icmp ne i8 [[TMP6]], [[TMP10]]
49 ; ABORT-INLINE-NEXT: br i1 [[TMP11]], label [[TMP12:%.*]], label [[TMP26:%.*]], !prof [[PROF1:![0-9]+]]
51 ; ABORT-INLINE-NEXT: [[TMP13:%.*]] = icmp ugt i8 [[TMP10]], 15
52 ; ABORT-INLINE-NEXT: br i1 [[TMP13]], label [[TMP14:%.*]], label [[TMP15:%.*]], !prof [[PROF1]]
54 ; ABORT-INLINE-NEXT: call void asm sideeffect "int3\0Anopl 64([[RAX:%.*]])", "{rdi}"(i64 [[TMP4]])
55 ; ABORT-INLINE-NEXT: unreachable
57 ; ABORT-INLINE-NEXT: [[TMP16:%.*]] = and i64 [[TMP4]], 15
58 ; ABORT-INLINE-NEXT: [[TMP17:%.*]] = trunc i64 [[TMP16]] to i8
59 ; ABORT-INLINE-NEXT: [[TMP18:%.*]] = add i8 [[TMP17]], 0
60 ; ABORT-INLINE-NEXT: [[TMP19:%.*]] = icmp uge i8 [[TMP18]], [[TMP10]]
61 ; ABORT-INLINE-NEXT: br i1 [[TMP19]], label [[TMP14]], label [[TMP20:%.*]], !prof [[PROF1]]
63 ; ABORT-INLINE-NEXT: [[TMP21:%.*]] = or i64 [[TMP7]], 15
64 ; ABORT-INLINE-NEXT: [[TMP22:%.*]] = inttoptr i64 [[TMP21]] to ptr
65 ; ABORT-INLINE-NEXT: [[TMP23:%.*]] = load i8, ptr [[TMP22]], align 1
66 ; ABORT-INLINE-NEXT: [[TMP24:%.*]] = icmp ne i8 [[TMP6]], [[TMP23]]
67 ; ABORT-INLINE-NEXT: br i1 [[TMP24]], label [[TMP14]], label [[TMP25:%.*]], !prof [[PROF1]]
69 ; ABORT-INLINE-NEXT: br label [[TMP26]]
71 ; ABORT-INLINE-NEXT: [[B:%.*]] = load i8, ptr [[A]], align 4
72 ; ABORT-INLINE-NEXT: ret i8 [[B]]
74 ; RECOVER-INLINE-LABEL: define i8 @test_load8
75 ; RECOVER-INLINE-SAME: (ptr [[A:%.*]]) #[[ATTR0:[0-9]+]] {
76 ; RECOVER-INLINE-NEXT: entry:
77 ; RECOVER-INLINE-NEXT: [[TMP0:%.*]] = load i64, ptr @__hwasan_tls, align 8
78 ; RECOVER-INLINE-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], -9079256848778919937
79 ; RECOVER-INLINE-NEXT: [[TMP2:%.*]] = or i64 [[TMP1]], 4294967295
80 ; RECOVER-INLINE-NEXT: [[HWASAN_SHADOW:%.*]] = add i64 [[TMP2]], 1
81 ; RECOVER-INLINE-NEXT: [[TMP3:%.*]] = inttoptr i64 [[HWASAN_SHADOW]] to ptr
82 ; RECOVER-INLINE-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[A]] to i64
83 ; RECOVER-INLINE-NEXT: [[TMP5:%.*]] = lshr i64 [[TMP4]], 57
84 ; RECOVER-INLINE-NEXT: [[TMP6:%.*]] = trunc i64 [[TMP5]] to i8
85 ; RECOVER-INLINE-NEXT: [[TMP7:%.*]] = and i64 [[TMP4]], -9079256848778919937
86 ; RECOVER-INLINE-NEXT: [[TMP8:%.*]] = lshr i64 [[TMP7]], 4
87 ; RECOVER-INLINE-NEXT: [[TMP9:%.*]] = getelementptr i8, ptr [[TMP3]], i64 [[TMP8]]
88 ; RECOVER-INLINE-NEXT: [[TMP10:%.*]] = load i8, ptr [[TMP9]], align 1
89 ; RECOVER-INLINE-NEXT: [[TMP11:%.*]] = icmp ne i8 [[TMP6]], [[TMP10]]
90 ; RECOVER-INLINE-NEXT: br i1 [[TMP11]], label [[TMP12:%.*]], label [[TMP26:%.*]], !prof [[PROF1:![0-9]+]]
92 ; RECOVER-INLINE-NEXT: [[TMP13:%.*]] = icmp ugt i8 [[TMP10]], 15
93 ; RECOVER-INLINE-NEXT: br i1 [[TMP13]], label [[TMP14:%.*]], label [[TMP15:%.*]], !prof [[PROF1]]
95 ; RECOVER-INLINE-NEXT: call void asm sideeffect "int3\0Anopl 96([[RAX:%.*]])", "{rdi}"(i64 [[TMP4]])
96 ; RECOVER-INLINE-NEXT: br label [[TMP25:%.*]]
98 ; RECOVER-INLINE-NEXT: [[TMP16:%.*]] = and i64 [[TMP4]], 15
99 ; RECOVER-INLINE-NEXT: [[TMP17:%.*]] = trunc i64 [[TMP16]] to i8
100 ; RECOVER-INLINE-NEXT: [[TMP18:%.*]] = add i8 [[TMP17]], 0
101 ; RECOVER-INLINE-NEXT: [[TMP19:%.*]] = icmp uge i8 [[TMP18]], [[TMP10]]
102 ; RECOVER-INLINE-NEXT: br i1 [[TMP19]], label [[TMP14]], label [[TMP20:%.*]], !prof [[PROF1]]
103 ; RECOVER-INLINE: 20:
104 ; RECOVER-INLINE-NEXT: [[TMP21:%.*]] = or i64 [[TMP7]], 15
105 ; RECOVER-INLINE-NEXT: [[TMP22:%.*]] = inttoptr i64 [[TMP21]] to ptr
106 ; RECOVER-INLINE-NEXT: [[TMP23:%.*]] = load i8, ptr [[TMP22]], align 1
107 ; RECOVER-INLINE-NEXT: [[TMP24:%.*]] = icmp ne i8 [[TMP6]], [[TMP23]]
108 ; RECOVER-INLINE-NEXT: br i1 [[TMP24]], label [[TMP14]], label [[TMP25]], !prof [[PROF1]]
109 ; RECOVER-INLINE: 25:
110 ; RECOVER-INLINE-NEXT: br label [[TMP26]]
111 ; RECOVER-INLINE: 26:
112 ; RECOVER-INLINE-NEXT: [[B:%.*]] = load i8, ptr [[A]], align 4
113 ; RECOVER-INLINE-NEXT: ret i8 [[B]]
119 %b = load i8, ptr %a, align 4
123 define i40 @test_load40(ptr %a) sanitize_hwaddress {
124 ; ABORT-LABEL: define i40 @test_load40
125 ; ABORT-SAME: (ptr [[A:%.*]]) #[[ATTR0]] {
127 ; ABORT-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
128 ; ABORT-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
129 ; ABORT-NEXT: call void @__hwasan_loadN(i64 [[TMP0]], i64 5)
130 ; ABORT-NEXT: [[B:%.*]] = load i40, ptr [[A]], align 4
131 ; ABORT-NEXT: ret i40 [[B]]
133 ; RECOVER-LABEL: define i40 @test_load40
134 ; RECOVER-SAME: (ptr [[A:%.*]]) #[[ATTR0]] {
135 ; RECOVER-NEXT: entry:
136 ; RECOVER-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
137 ; RECOVER-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
138 ; RECOVER-NEXT: call void @__hwasan_loadN_noabort(i64 [[TMP0]], i64 5)
139 ; RECOVER-NEXT: [[B:%.*]] = load i40, ptr [[A]], align 4
140 ; RECOVER-NEXT: ret i40 [[B]]
142 ; ABORT-INLINE-LABEL: define i40 @test_load40
143 ; ABORT-INLINE-SAME: (ptr [[A:%.*]]) #[[ATTR0]] {
144 ; ABORT-INLINE-NEXT: entry:
145 ; ABORT-INLINE-NEXT: [[TMP0:%.*]] = load i64, ptr @__hwasan_tls, align 8
146 ; ABORT-INLINE-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], -9079256848778919937
147 ; ABORT-INLINE-NEXT: [[TMP2:%.*]] = or i64 [[TMP1]], 4294967295
148 ; ABORT-INLINE-NEXT: [[HWASAN_SHADOW:%.*]] = add i64 [[TMP2]], 1
149 ; ABORT-INLINE-NEXT: [[TMP3:%.*]] = inttoptr i64 [[HWASAN_SHADOW]] to ptr
150 ; ABORT-INLINE-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[A]] to i64
151 ; ABORT-INLINE-NEXT: call void @__hwasan_loadN(i64 [[TMP4]], i64 5)
152 ; ABORT-INLINE-NEXT: [[B:%.*]] = load i40, ptr [[A]], align 4
153 ; ABORT-INLINE-NEXT: ret i40 [[B]]
155 ; RECOVER-INLINE-LABEL: define i40 @test_load40
156 ; RECOVER-INLINE-SAME: (ptr [[A:%.*]]) #[[ATTR0]] {
157 ; RECOVER-INLINE-NEXT: entry:
158 ; RECOVER-INLINE-NEXT: [[TMP0:%.*]] = load i64, ptr @__hwasan_tls, align 8
159 ; RECOVER-INLINE-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], -9079256848778919937
160 ; RECOVER-INLINE-NEXT: [[TMP2:%.*]] = or i64 [[TMP1]], 4294967295
161 ; RECOVER-INLINE-NEXT: [[HWASAN_SHADOW:%.*]] = add i64 [[TMP2]], 1
162 ; RECOVER-INLINE-NEXT: [[TMP3:%.*]] = inttoptr i64 [[HWASAN_SHADOW]] to ptr
163 ; RECOVER-INLINE-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[A]] to i64
164 ; RECOVER-INLINE-NEXT: call void @__hwasan_loadN_noabort(i64 [[TMP4]], i64 5)
165 ; RECOVER-INLINE-NEXT: [[B:%.*]] = load i40, ptr [[A]], align 4
166 ; RECOVER-INLINE-NEXT: ret i40 [[B]]
172 %b = load i40, ptr %a, align 4
176 define void @test_store8(ptr %a, i8 %b) sanitize_hwaddress {
177 ; ABORT-LABEL: define void @test_store8
178 ; ABORT-SAME: (ptr [[A:%.*]], i8 [[B:%.*]]) #[[ATTR0]] {
180 ; ABORT-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
181 ; ABORT-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
182 ; ABORT-NEXT: call void @__hwasan_store1(i64 [[TMP0]])
183 ; ABORT-NEXT: store i8 [[B]], ptr [[A]], align 4
184 ; ABORT-NEXT: ret void
186 ; RECOVER-LABEL: define void @test_store8
187 ; RECOVER-SAME: (ptr [[A:%.*]], i8 [[B:%.*]]) #[[ATTR0]] {
188 ; RECOVER-NEXT: entry:
189 ; RECOVER-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
190 ; RECOVER-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
191 ; RECOVER-NEXT: call void @__hwasan_store1_noabort(i64 [[TMP0]])
192 ; RECOVER-NEXT: store i8 [[B]], ptr [[A]], align 4
193 ; RECOVER-NEXT: ret void
195 ; ABORT-INLINE-LABEL: define void @test_store8
196 ; ABORT-INLINE-SAME: (ptr [[A:%.*]], i8 [[B:%.*]]) #[[ATTR0]] {
197 ; ABORT-INLINE-NEXT: entry:
198 ; ABORT-INLINE-NEXT: [[TMP0:%.*]] = load i64, ptr @__hwasan_tls, align 8
199 ; ABORT-INLINE-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], -9079256848778919937
200 ; ABORT-INLINE-NEXT: [[TMP2:%.*]] = or i64 [[TMP1]], 4294967295
201 ; ABORT-INLINE-NEXT: [[HWASAN_SHADOW:%.*]] = add i64 [[TMP2]], 1
202 ; ABORT-INLINE-NEXT: [[TMP3:%.*]] = inttoptr i64 [[HWASAN_SHADOW]] to ptr
203 ; ABORT-INLINE-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[A]] to i64
204 ; ABORT-INLINE-NEXT: [[TMP5:%.*]] = lshr i64 [[TMP4]], 57
205 ; ABORT-INLINE-NEXT: [[TMP6:%.*]] = trunc i64 [[TMP5]] to i8
206 ; ABORT-INLINE-NEXT: [[TMP7:%.*]] = and i64 [[TMP4]], -9079256848778919937
207 ; ABORT-INLINE-NEXT: [[TMP8:%.*]] = lshr i64 [[TMP7]], 4
208 ; ABORT-INLINE-NEXT: [[TMP9:%.*]] = getelementptr i8, ptr [[TMP3]], i64 [[TMP8]]
209 ; ABORT-INLINE-NEXT: [[TMP10:%.*]] = load i8, ptr [[TMP9]], align 1
210 ; ABORT-INLINE-NEXT: [[TMP11:%.*]] = icmp ne i8 [[TMP6]], [[TMP10]]
211 ; ABORT-INLINE-NEXT: br i1 [[TMP11]], label [[TMP12:%.*]], label [[TMP26:%.*]], !prof [[PROF1]]
213 ; ABORT-INLINE-NEXT: [[TMP13:%.*]] = icmp ugt i8 [[TMP10]], 15
214 ; ABORT-INLINE-NEXT: br i1 [[TMP13]], label [[TMP14:%.*]], label [[TMP15:%.*]], !prof [[PROF1]]
216 ; ABORT-INLINE-NEXT: call void asm sideeffect "int3\0Anopl 80([[RAX:%.*]])", "{rdi}"(i64 [[TMP4]])
217 ; ABORT-INLINE-NEXT: unreachable
219 ; ABORT-INLINE-NEXT: [[TMP16:%.*]] = and i64 [[TMP4]], 15
220 ; ABORT-INLINE-NEXT: [[TMP17:%.*]] = trunc i64 [[TMP16]] to i8
221 ; ABORT-INLINE-NEXT: [[TMP18:%.*]] = add i8 [[TMP17]], 0
222 ; ABORT-INLINE-NEXT: [[TMP19:%.*]] = icmp uge i8 [[TMP18]], [[TMP10]]
223 ; ABORT-INLINE-NEXT: br i1 [[TMP19]], label [[TMP14]], label [[TMP20:%.*]], !prof [[PROF1]]
225 ; ABORT-INLINE-NEXT: [[TMP21:%.*]] = or i64 [[TMP7]], 15
226 ; ABORT-INLINE-NEXT: [[TMP22:%.*]] = inttoptr i64 [[TMP21]] to ptr
227 ; ABORT-INLINE-NEXT: [[TMP23:%.*]] = load i8, ptr [[TMP22]], align 1
228 ; ABORT-INLINE-NEXT: [[TMP24:%.*]] = icmp ne i8 [[TMP6]], [[TMP23]]
229 ; ABORT-INLINE-NEXT: br i1 [[TMP24]], label [[TMP14]], label [[TMP25:%.*]], !prof [[PROF1]]
231 ; ABORT-INLINE-NEXT: br label [[TMP26]]
233 ; ABORT-INLINE-NEXT: store i8 [[B]], ptr [[A]], align 4
234 ; ABORT-INLINE-NEXT: ret void
236 ; RECOVER-INLINE-LABEL: define void @test_store8
237 ; RECOVER-INLINE-SAME: (ptr [[A:%.*]], i8 [[B:%.*]]) #[[ATTR0]] {
238 ; RECOVER-INLINE-NEXT: entry:
239 ; RECOVER-INLINE-NEXT: [[TMP0:%.*]] = load i64, ptr @__hwasan_tls, align 8
240 ; RECOVER-INLINE-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], -9079256848778919937
241 ; RECOVER-INLINE-NEXT: [[TMP2:%.*]] = or i64 [[TMP1]], 4294967295
242 ; RECOVER-INLINE-NEXT: [[HWASAN_SHADOW:%.*]] = add i64 [[TMP2]], 1
243 ; RECOVER-INLINE-NEXT: [[TMP3:%.*]] = inttoptr i64 [[HWASAN_SHADOW]] to ptr
244 ; RECOVER-INLINE-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[A]] to i64
245 ; RECOVER-INLINE-NEXT: [[TMP5:%.*]] = lshr i64 [[TMP4]], 57
246 ; RECOVER-INLINE-NEXT: [[TMP6:%.*]] = trunc i64 [[TMP5]] to i8
247 ; RECOVER-INLINE-NEXT: [[TMP7:%.*]] = and i64 [[TMP4]], -9079256848778919937
248 ; RECOVER-INLINE-NEXT: [[TMP8:%.*]] = lshr i64 [[TMP7]], 4
249 ; RECOVER-INLINE-NEXT: [[TMP9:%.*]] = getelementptr i8, ptr [[TMP3]], i64 [[TMP8]]
250 ; RECOVER-INLINE-NEXT: [[TMP10:%.*]] = load i8, ptr [[TMP9]], align 1
251 ; RECOVER-INLINE-NEXT: [[TMP11:%.*]] = icmp ne i8 [[TMP6]], [[TMP10]]
252 ; RECOVER-INLINE-NEXT: br i1 [[TMP11]], label [[TMP12:%.*]], label [[TMP26:%.*]], !prof [[PROF1]]
253 ; RECOVER-INLINE: 12:
254 ; RECOVER-INLINE-NEXT: [[TMP13:%.*]] = icmp ugt i8 [[TMP10]], 15
255 ; RECOVER-INLINE-NEXT: br i1 [[TMP13]], label [[TMP14:%.*]], label [[TMP15:%.*]], !prof [[PROF1]]
256 ; RECOVER-INLINE: 14:
257 ; RECOVER-INLINE-NEXT: call void asm sideeffect "int3\0Anopl 112([[RAX:%.*]])", "{rdi}"(i64 [[TMP4]])
258 ; RECOVER-INLINE-NEXT: br label [[TMP25:%.*]]
259 ; RECOVER-INLINE: 15:
260 ; RECOVER-INLINE-NEXT: [[TMP16:%.*]] = and i64 [[TMP4]], 15
261 ; RECOVER-INLINE-NEXT: [[TMP17:%.*]] = trunc i64 [[TMP16]] to i8
262 ; RECOVER-INLINE-NEXT: [[TMP18:%.*]] = add i8 [[TMP17]], 0
263 ; RECOVER-INLINE-NEXT: [[TMP19:%.*]] = icmp uge i8 [[TMP18]], [[TMP10]]
264 ; RECOVER-INLINE-NEXT: br i1 [[TMP19]], label [[TMP14]], label [[TMP20:%.*]], !prof [[PROF1]]
265 ; RECOVER-INLINE: 20:
266 ; RECOVER-INLINE-NEXT: [[TMP21:%.*]] = or i64 [[TMP7]], 15
267 ; RECOVER-INLINE-NEXT: [[TMP22:%.*]] = inttoptr i64 [[TMP21]] to ptr
268 ; RECOVER-INLINE-NEXT: [[TMP23:%.*]] = load i8, ptr [[TMP22]], align 1
269 ; RECOVER-INLINE-NEXT: [[TMP24:%.*]] = icmp ne i8 [[TMP6]], [[TMP23]]
270 ; RECOVER-INLINE-NEXT: br i1 [[TMP24]], label [[TMP14]], label [[TMP25]], !prof [[PROF1]]
271 ; RECOVER-INLINE: 25:
272 ; RECOVER-INLINE-NEXT: br label [[TMP26]]
273 ; RECOVER-INLINE: 26:
274 ; RECOVER-INLINE-NEXT: store i8 [[B]], ptr [[A]], align 4
275 ; RECOVER-INLINE-NEXT: ret void
281 store i8 %b, ptr %a, align 4
285 define void @test_store40(ptr %a, i40 %b) sanitize_hwaddress {
286 ; ABORT-LABEL: define void @test_store40
287 ; ABORT-SAME: (ptr [[A:%.*]], i40 [[B:%.*]]) #[[ATTR0]] {
289 ; ABORT-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
290 ; ABORT-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
291 ; ABORT-NEXT: call void @__hwasan_storeN(i64 [[TMP0]], i64 5)
292 ; ABORT-NEXT: store i40 [[B]], ptr [[A]], align 4
293 ; ABORT-NEXT: ret void
295 ; RECOVER-LABEL: define void @test_store40
296 ; RECOVER-SAME: (ptr [[A:%.*]], i40 [[B:%.*]]) #[[ATTR0]] {
297 ; RECOVER-NEXT: entry:
298 ; RECOVER-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
299 ; RECOVER-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
300 ; RECOVER-NEXT: call void @__hwasan_storeN_noabort(i64 [[TMP0]], i64 5)
301 ; RECOVER-NEXT: store i40 [[B]], ptr [[A]], align 4
302 ; RECOVER-NEXT: ret void
304 ; ABORT-INLINE-LABEL: define void @test_store40
305 ; ABORT-INLINE-SAME: (ptr [[A:%.*]], i40 [[B:%.*]]) #[[ATTR0]] {
306 ; ABORT-INLINE-NEXT: entry:
307 ; ABORT-INLINE-NEXT: [[TMP0:%.*]] = load i64, ptr @__hwasan_tls, align 8
308 ; ABORT-INLINE-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], -9079256848778919937
309 ; ABORT-INLINE-NEXT: [[TMP2:%.*]] = or i64 [[TMP1]], 4294967295
310 ; ABORT-INLINE-NEXT: [[HWASAN_SHADOW:%.*]] = add i64 [[TMP2]], 1
311 ; ABORT-INLINE-NEXT: [[TMP3:%.*]] = inttoptr i64 [[HWASAN_SHADOW]] to ptr
312 ; ABORT-INLINE-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[A]] to i64
313 ; ABORT-INLINE-NEXT: call void @__hwasan_storeN(i64 [[TMP4]], i64 5)
314 ; ABORT-INLINE-NEXT: store i40 [[B]], ptr [[A]], align 4
315 ; ABORT-INLINE-NEXT: ret void
317 ; RECOVER-INLINE-LABEL: define void @test_store40
318 ; RECOVER-INLINE-SAME: (ptr [[A:%.*]], i40 [[B:%.*]]) #[[ATTR0]] {
319 ; RECOVER-INLINE-NEXT: entry:
320 ; RECOVER-INLINE-NEXT: [[TMP0:%.*]] = load i64, ptr @__hwasan_tls, align 8
321 ; RECOVER-INLINE-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], -9079256848778919937
322 ; RECOVER-INLINE-NEXT: [[TMP2:%.*]] = or i64 [[TMP1]], 4294967295
323 ; RECOVER-INLINE-NEXT: [[HWASAN_SHADOW:%.*]] = add i64 [[TMP2]], 1
324 ; RECOVER-INLINE-NEXT: [[TMP3:%.*]] = inttoptr i64 [[HWASAN_SHADOW]] to ptr
325 ; RECOVER-INLINE-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[A]] to i64
326 ; RECOVER-INLINE-NEXT: call void @__hwasan_storeN_noabort(i64 [[TMP4]], i64 5)
327 ; RECOVER-INLINE-NEXT: store i40 [[B]], ptr [[A]], align 4
328 ; RECOVER-INLINE-NEXT: ret void
334 store i40 %b, ptr %a, align 4
338 define void @test_store_unaligned(ptr %a, i64 %b) sanitize_hwaddress {
339 ; ABORT-LABEL: define void @test_store_unaligned
340 ; ABORT-SAME: (ptr [[A:%.*]], i64 [[B:%.*]]) #[[ATTR0]] {
342 ; ABORT-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
343 ; ABORT-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
344 ; ABORT-NEXT: call void @__hwasan_storeN(i64 [[TMP0]], i64 8)
345 ; ABORT-NEXT: store i64 [[B]], ptr [[A]], align 4
346 ; ABORT-NEXT: ret void
348 ; RECOVER-LABEL: define void @test_store_unaligned
349 ; RECOVER-SAME: (ptr [[A:%.*]], i64 [[B:%.*]]) #[[ATTR0]] {
350 ; RECOVER-NEXT: entry:
351 ; RECOVER-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
352 ; RECOVER-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
353 ; RECOVER-NEXT: call void @__hwasan_storeN_noabort(i64 [[TMP0]], i64 8)
354 ; RECOVER-NEXT: store i64 [[B]], ptr [[A]], align 4
355 ; RECOVER-NEXT: ret void
357 ; ABORT-INLINE-LABEL: define void @test_store_unaligned
358 ; ABORT-INLINE-SAME: (ptr [[A:%.*]], i64 [[B:%.*]]) #[[ATTR0]] {
359 ; ABORT-INLINE-NEXT: entry:
360 ; ABORT-INLINE-NEXT: [[TMP0:%.*]] = load i64, ptr @__hwasan_tls, align 8
361 ; ABORT-INLINE-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], -9079256848778919937
362 ; ABORT-INLINE-NEXT: [[TMP2:%.*]] = or i64 [[TMP1]], 4294967295
363 ; ABORT-INLINE-NEXT: [[HWASAN_SHADOW:%.*]] = add i64 [[TMP2]], 1
364 ; ABORT-INLINE-NEXT: [[TMP3:%.*]] = inttoptr i64 [[HWASAN_SHADOW]] to ptr
365 ; ABORT-INLINE-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[A]] to i64
366 ; ABORT-INLINE-NEXT: call void @__hwasan_storeN(i64 [[TMP4]], i64 8)
367 ; ABORT-INLINE-NEXT: store i64 [[B]], ptr [[A]], align 4
368 ; ABORT-INLINE-NEXT: ret void
370 ; RECOVER-INLINE-LABEL: define void @test_store_unaligned
371 ; RECOVER-INLINE-SAME: (ptr [[A:%.*]], i64 [[B:%.*]]) #[[ATTR0]] {
372 ; RECOVER-INLINE-NEXT: entry:
373 ; RECOVER-INLINE-NEXT: [[TMP0:%.*]] = load i64, ptr @__hwasan_tls, align 8
374 ; RECOVER-INLINE-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], -9079256848778919937
375 ; RECOVER-INLINE-NEXT: [[TMP2:%.*]] = or i64 [[TMP1]], 4294967295
376 ; RECOVER-INLINE-NEXT: [[HWASAN_SHADOW:%.*]] = add i64 [[TMP2]], 1
377 ; RECOVER-INLINE-NEXT: [[TMP3:%.*]] = inttoptr i64 [[HWASAN_SHADOW]] to ptr
378 ; RECOVER-INLINE-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[A]] to i64
379 ; RECOVER-INLINE-NEXT: call void @__hwasan_storeN_noabort(i64 [[TMP4]], i64 8)
380 ; RECOVER-INLINE-NEXT: store i64 [[B]], ptr [[A]], align 4
381 ; RECOVER-INLINE-NEXT: ret void
387 store i64 %b, ptr %a, align 4