1 ; Test basic address sanitizer instrumentation.
3 ; RUN: opt < %s -hwasan -hwasan-recover=0 -hwasan-with-ifunc=1 -hwasan-with-tls=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT,ABORT-DYNAMIC-SHADOW
4 ; RUN: opt < %s -hwasan -hwasan-recover=1 -hwasan-with-ifunc=1 -hwasan-with-tls=0 -S | FileCheck %s --check-prefixes=CHECK,RECOVER,RECOVER-DYNAMIC-SHADOW
5 ; RUN: opt < %s -hwasan -hwasan-recover=0 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT,ABORT-ZERO-BASED-SHADOW
6 ; RUN: opt < %s -hwasan -hwasan-recover=1 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,RECOVER,RECOVER-ZERO-BASED-SHADOW
8 ; Ensure than hwasan runs with the new PM pass
9 ; RUN: opt < %s -passes=hwasan -hwasan-recover=0 -hwasan-with-ifunc=1 -hwasan-with-tls=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT,ABORT-DYNAMIC-SHADOW
10 ; RUN: opt < %s -passes=hwasan -hwasan-recover=1 -hwasan-with-ifunc=1 -hwasan-with-tls=0 -S | FileCheck %s --check-prefixes=CHECK,RECOVER,RECOVER-DYNAMIC-SHADOW
11 ; RUN: opt < %s -passes=hwasan -hwasan-recover=0 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT,ABORT-ZERO-BASED-SHADOW
12 ; RUN: opt < %s -passes=hwasan -hwasan-recover=1 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,RECOVER,RECOVER-ZERO-BASED-SHADOW
14 ; CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @hwasan.module_ctor, i8* bitcast (void ()* @hwasan.module_ctor to i8*) }]
16 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
17 target triple = "aarch64--linux-android10000"
19 define i8 @test_load8(i8* %a) sanitize_hwaddress {
20 ; CHECK-LABEL: @test_load8(
21 ; RECOVER: %[[A:[^ ]*]] = ptrtoint i8* %a to i64
22 ; RECOVER: %[[B:[^ ]*]] = lshr i64 %[[A]], 56
23 ; RECOVER: %[[PTRTAG:[^ ]*]] = trunc i64 %[[B]] to i8
24 ; RECOVER: %[[C:[^ ]*]] = and i64 %[[A]], 72057594037927935
25 ; RECOVER: %[[D:[^ ]*]] = lshr i64 %[[C]], 4
26 ; RECOVER-DYNAMIC-SHADOW: %[[E:[^ ]*]] = getelementptr i8, i8* %.hwasan.shadow, i64 %4
27 ; RECOVER-ZERO-BASED-SHADOW: %[[E:[^ ]*]] = inttoptr i64 %[[D]] to i8*
28 ; RECOVER: %[[MEMTAG:[^ ]*]] = load i8, i8* %[[E]]
29 ; RECOVER: %[[F:[^ ]*]] = icmp ne i8 %[[PTRTAG]], %[[MEMTAG]]
30 ; RECOVER: br i1 %[[F]], label %[[MISMATCH:[0-9]*]], label %[[CONT:[0-9]*]], !prof {{.*}}
32 ; RECOVER: [[MISMATCH]]:
33 ; RECOVER: %[[NOTSHORT:[^ ]*]] = icmp ugt i8 %[[MEMTAG]], 15
34 ; RECOVER: br i1 %[[NOTSHORT]], label %[[FAIL:[0-9]*]], label %[[SHORT:[0-9]*]], !prof {{.*}}
37 ; RECOVER: call void asm sideeffect "brk #2336", "{x0}"(i64 %[[A]])
41 ; RECOVER: %[[LOWBITS:[^ ]*]] = and i64 %[[A]], 15
42 ; RECOVER: %[[LOWBITS_I8:[^ ]*]] = trunc i64 %[[LOWBITS]] to i8
43 ; RECOVER: %[[LAST:[^ ]*]] = add i8 %[[LOWBITS_I8]], 0
44 ; RECOVER: %[[OOB:[^ ]*]] = icmp uge i8 %[[LAST]], %[[MEMTAG]]
45 ; RECOVER: br i1 %[[OOB]], label %[[FAIL]], label %[[INBOUNDS:[0-9]*]], !prof {{.*}}
47 ; RECOVER: [[INBOUNDS]]:
48 ; RECOVER: %[[EOG_ADDR:[^ ]*]] = or i64 %[[C]], 15
49 ; RECOVER: %[[EOG_PTR:[^ ]*]] = inttoptr i64 %[[EOG_ADDR]] to i8*
50 ; RECOVER: %[[EOGTAG:[^ ]*]] = load i8, i8* %[[EOG_PTR]]
51 ; RECOVER: %[[EOG_MISMATCH:[^ ]*]] = icmp ne i8 %[[PTRTAG]], %[[EOGTAG]]
52 ; RECOVER: br i1 %[[EOG_MISMATCH]], label %[[FAIL]], label %[[CONT1:[0-9]*]], !prof {{.*}}
55 ; RECOVER: br label %[[CONT]]
59 ; ABORT-DYNAMIC-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* %.hwasan.shadow, i8* %a, i32 0)
60 ; ABORT-ZERO-BASED-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* null, i8* %a, i32 0)
62 ; CHECK: %[[G:[^ ]*]] = load i8, i8* %a, align 4
63 ; CHECK: ret i8 %[[G]]
66 %b = load i8, i8* %a, align 4
70 define i16 @test_load16(i16* %a) sanitize_hwaddress {
71 ; CHECK-LABEL: @test_load16(
72 ; RECOVER: %[[A:[^ ]*]] = ptrtoint i16* %a to i64
73 ; RECOVER: %[[B:[^ ]*]] = lshr i64 %[[A]], 56
74 ; RECOVER: %[[PTRTAG:[^ ]*]] = trunc i64 %[[B]] to i8
75 ; RECOVER: %[[C:[^ ]*]] = and i64 %[[A]], 72057594037927935
76 ; RECOVER: %[[D:[^ ]*]] = lshr i64 %[[C]], 4
77 ; RECOVER-DYNAMIC-SHADOW: %[[E:[^ ]*]] = getelementptr i8, i8* %.hwasan.shadow, i64 %4
78 ; RECOVER-ZERO-BASED-SHADOW: %[[E:[^ ]*]] = inttoptr i64 %[[D]] to i8*
79 ; RECOVER: %[[MEMTAG:[^ ]*]] = load i8, i8* %[[E]]
80 ; RECOVER: %[[F:[^ ]*]] = icmp ne i8 %[[PTRTAG]], %[[MEMTAG]]
81 ; RECOVER: br i1 %[[F]], label %[[MISMATCH:[0-9]*]], label %[[CONT:[0-9]*]], !prof {{.*}}
83 ; RECOVER: [[MISMATCH]]:
84 ; RECOVER: %[[NOTSHORT:[^ ]*]] = icmp ugt i8 %[[MEMTAG]], 15
85 ; RECOVER: br i1 %[[NOTSHORT]], label %[[FAIL:[0-9]*]], label %[[SHORT:[0-9]*]], !prof {{.*}}
88 ; RECOVER: call void asm sideeffect "brk #2337", "{x0}"(i64 %[[A]])
92 ; RECOVER: %[[LOWBITS:[^ ]*]] = and i64 %[[A]], 15
93 ; RECOVER: %[[LOWBITS_I8:[^ ]*]] = trunc i64 %[[LOWBITS]] to i8
94 ; RECOVER: %[[LAST:[^ ]*]] = add i8 %[[LOWBITS_I8]], 1
95 ; RECOVER: %[[OOB:[^ ]*]] = icmp uge i8 %[[LAST]], %[[MEMTAG]]
96 ; RECOVER: br i1 %[[OOB]], label %[[FAIL]], label %[[INBOUNDS:[0-9]*]], !prof {{.*}}
98 ; RECOVER: [[INBOUNDS]]:
99 ; RECOVER: %[[EOG_ADDR:[^ ]*]] = or i64 %[[C]], 15
100 ; RECOVER: %[[EOG_PTR:[^ ]*]] = inttoptr i64 %[[EOG_ADDR]] to i8*
101 ; RECOVER: %[[EOGTAG:[^ ]*]] = load i8, i8* %[[EOG_PTR]]
102 ; RECOVER: %[[EOG_MISMATCH:[^ ]*]] = icmp ne i8 %[[PTRTAG]], %[[EOGTAG]]
103 ; RECOVER: br i1 %[[EOG_MISMATCH]], label %[[FAIL]], label %[[CONT1:[0-9]*]], !prof {{.*}}
105 ; RECOVER: [[CONT1]]:
106 ; RECOVER: br label %[[CONT]]
110 ; ABORT: %[[A:[^ ]*]] = bitcast i16* %a to i8*
111 ; ABORT-DYNAMIC-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* %.hwasan.shadow, i8* %[[A]], i32 1)
112 ; ABORT-ZERO-BASED-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* null, i8* %[[A]], i32 1)
114 ; CHECK: %[[G:[^ ]*]] = load i16, i16* %a, align 4
115 ; CHECK: ret i16 %[[G]]
118 %b = load i16, i16* %a, align 4
122 define i32 @test_load32(i32* %a) sanitize_hwaddress {
123 ; CHECK-LABEL: @test_load32(
124 ; RECOVER: %[[A:[^ ]*]] = ptrtoint i32* %a to i64
125 ; RECOVER: %[[B:[^ ]*]] = lshr i64 %[[A]], 56
126 ; RECOVER: %[[PTRTAG:[^ ]*]] = trunc i64 %[[B]] to i8
127 ; RECOVER: %[[C:[^ ]*]] = and i64 %[[A]], 72057594037927935
128 ; RECOVER: %[[D:[^ ]*]] = lshr i64 %[[C]], 4
129 ; RECOVER-DYNAMIC-SHADOW: %[[E:[^ ]*]] = getelementptr i8, i8* %.hwasan.shadow, i64 %4
130 ; RECOVER-ZERO-BASED-SHADOW: %[[E:[^ ]*]] = inttoptr i64 %[[D]] to i8*
131 ; RECOVER: %[[MEMTAG:[^ ]*]] = load i8, i8* %[[E]]
132 ; RECOVER: %[[F:[^ ]*]] = icmp ne i8 %[[PTRTAG]], %[[MEMTAG]]
133 ; RECOVER: br i1 %[[F]], label {{.*}}, label {{.*}}, !prof {{.*}}
135 ; RECOVER: call void asm sideeffect "brk #2338", "{x0}"(i64 %[[A]])
138 ; ABORT: %[[A:[^ ]*]] = bitcast i32* %a to i8*
139 ; ABORT-DYNAMIC-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* %.hwasan.shadow, i8* %[[A]], i32 2)
140 ; ABORT-ZERO-BASED-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* null, i8* %[[A]], i32 2)
142 ; CHECK: %[[G:[^ ]*]] = load i32, i32* %a, align 4
143 ; CHECK: ret i32 %[[G]]
146 %b = load i32, i32* %a, align 4
150 define i64 @test_load64(i64* %a) sanitize_hwaddress {
151 ; CHECK-LABEL: @test_load64(
152 ; RECOVER: %[[A:[^ ]*]] = ptrtoint i64* %a to i64
153 ; RECOVER: %[[B:[^ ]*]] = lshr i64 %[[A]], 56
154 ; RECOVER: %[[PTRTAG:[^ ]*]] = trunc i64 %[[B]] to i8
155 ; RECOVER: %[[C:[^ ]*]] = and i64 %[[A]], 72057594037927935
156 ; RECOVER: %[[D:[^ ]*]] = lshr i64 %[[C]], 4
157 ; RECOVER-DYNAMIC-SHADOW: %[[E:[^ ]*]] = getelementptr i8, i8* %.hwasan.shadow, i64 %4
158 ; RECOVER-ZERO-BASED-SHADOW: %[[E:[^ ]*]] = inttoptr i64 %[[D]] to i8*
159 ; RECOVER: %[[MEMTAG:[^ ]*]] = load i8, i8* %[[E]]
160 ; RECOVER: %[[F:[^ ]*]] = icmp ne i8 %[[PTRTAG]], %[[MEMTAG]]
161 ; RECOVER: br i1 %[[F]], label {{.*}}, label {{.*}}, !prof {{.*}}
163 ; RECOVER: call void asm sideeffect "brk #2339", "{x0}"(i64 %[[A]])
166 ; ABORT: %[[A:[^ ]*]] = bitcast i64* %a to i8*
167 ; ABORT-DYNAMIC-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* %.hwasan.shadow, i8* %[[A]], i32 3)
168 ; ABORT-ZERO-BASED-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* null, i8* %[[A]], i32 3)
170 ; CHECK: %[[G:[^ ]*]] = load i64, i64* %a, align 8
171 ; CHECK: ret i64 %[[G]]
174 %b = load i64, i64* %a, align 8
178 define i128 @test_load128(i128* %a) sanitize_hwaddress {
179 ; CHECK-LABEL: @test_load128(
180 ; RECOVER: %[[A:[^ ]*]] = ptrtoint i128* %a to i64
181 ; RECOVER: %[[B:[^ ]*]] = lshr i64 %[[A]], 56
182 ; RECOVER: %[[PTRTAG:[^ ]*]] = trunc i64 %[[B]] to i8
183 ; RECOVER: %[[C:[^ ]*]] = and i64 %[[A]], 72057594037927935
184 ; RECOVER: %[[D:[^ ]*]] = lshr i64 %[[C]], 4
185 ; RECOVER-DYNAMIC-SHADOW: %[[E:[^ ]*]] = getelementptr i8, i8* %.hwasan.shadow, i64 %4
186 ; RECOVER-ZERO-BASED-SHADOW: %[[E:[^ ]*]] = inttoptr i64 %[[D]] to i8*
187 ; RECOVER: %[[MEMTAG:[^ ]*]] = load i8, i8* %[[E]]
188 ; RECOVER: %[[F:[^ ]*]] = icmp ne i8 %[[PTRTAG]], %[[MEMTAG]]
189 ; RECOVER: br i1 %[[F]], label {{.*}}, label {{.*}}, !prof {{.*}}
191 ; RECOVER: call void asm sideeffect "brk #2340", "{x0}"(i64 %[[A]])
194 ; ABORT: %[[A:[^ ]*]] = bitcast i128* %a to i8*
195 ; ABORT-DYNAMIC-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* %.hwasan.shadow, i8* %[[A]], i32 4)
196 ; ABORT-ZERO-BASED-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* null, i8* %[[A]], i32 4)
198 ; CHECK: %[[G:[^ ]*]] = load i128, i128* %a, align 16
199 ; CHECK: ret i128 %[[G]]
202 %b = load i128, i128* %a, align 16
206 define i40 @test_load40(i40* %a) sanitize_hwaddress {
207 ; CHECK-LABEL: @test_load40(
208 ; CHECK: %[[A:[^ ]*]] = ptrtoint i40* %a to i64
209 ; ABORT: call void @__hwasan_loadN(i64 %[[A]], i64 5)
210 ; RECOVER: call void @__hwasan_loadN_noabort(i64 %[[A]], i64 5)
211 ; CHECK: %[[B:[^ ]*]] = load i40, i40* %a
212 ; CHECK: ret i40 %[[B]]
215 %b = load i40, i40* %a, align 4
219 define void @test_store8(i8* %a, i8 %b) sanitize_hwaddress {
220 ; CHECK-LABEL: @test_store8(
221 ; RECOVER: %[[A:[^ ]*]] = ptrtoint i8* %a to i64
222 ; RECOVER: %[[B:[^ ]*]] = lshr i64 %[[A]], 56
223 ; RECOVER: %[[PTRTAG:[^ ]*]] = trunc i64 %[[B]] to i8
224 ; RECOVER: %[[C:[^ ]*]] = and i64 %[[A]], 72057594037927935
225 ; RECOVER: %[[D:[^ ]*]] = lshr i64 %[[C]], 4
226 ; RECOVER-DYNAMIC-SHADOW: %[[E:[^ ]*]] = getelementptr i8, i8* %.hwasan.shadow, i64 %4
227 ; RECOVER-ZERO-BASED-SHADOW: %[[E:[^ ]*]] = inttoptr i64 %[[D]] to i8*
228 ; RECOVER: %[[MEMTAG:[^ ]*]] = load i8, i8* %[[E]]
229 ; RECOVER: %[[F:[^ ]*]] = icmp ne i8 %[[PTRTAG]], %[[MEMTAG]]
230 ; RECOVER: br i1 %[[F]], label {{.*}}, label {{.*}}, !prof {{.*}}
232 ; RECOVER: call void asm sideeffect "brk #2352", "{x0}"(i64 %[[A]])
235 ; ABORT-DYNAMIC-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* %.hwasan.shadow, i8* %a, i32 16)
236 ; ABORT-ZERO-BASED-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* null, i8* %a, i32 16)
238 ; CHECK: store i8 %b, i8* %a, align 4
242 store i8 %b, i8* %a, align 4
246 define void @test_store16(i16* %a, i16 %b) sanitize_hwaddress {
247 ; CHECK-LABEL: @test_store16(
248 ; RECOVER: %[[A:[^ ]*]] = ptrtoint i16* %a to i64
249 ; RECOVER: %[[B:[^ ]*]] = lshr i64 %[[A]], 56
250 ; RECOVER: %[[PTRTAG:[^ ]*]] = trunc i64 %[[B]] to i8
251 ; RECOVER: %[[C:[^ ]*]] = and i64 %[[A]], 72057594037927935
252 ; RECOVER: %[[D:[^ ]*]] = lshr i64 %[[C]], 4
253 ; RECOVER-DYNAMIC-SHADOW: %[[E:[^ ]*]] = getelementptr i8, i8* %.hwasan.shadow, i64 %4
254 ; RECOVER-ZERO-BASED-SHADOW: %[[E:[^ ]*]] = inttoptr i64 %[[D]] to i8*
255 ; RECOVER: %[[MEMTAG:[^ ]*]] = load i8, i8* %[[E]]
256 ; RECOVER: %[[F:[^ ]*]] = icmp ne i8 %[[PTRTAG]], %[[MEMTAG]]
257 ; RECOVER: br i1 %[[F]], label {{.*}}, label {{.*}}, !prof {{.*}}
259 ; RECOVER: call void asm sideeffect "brk #2353", "{x0}"(i64 %[[A]])
262 ; ABORT: %[[A:[^ ]*]] = bitcast i16* %a to i8*
263 ; ABORT-DYNAMIC-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* %.hwasan.shadow, i8* %[[A]], i32 17)
264 ; ABORT-ZERO-BASED-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* null, i8* %[[A]], i32 17)
266 ; CHECK: store i16 %b, i16* %a, align 4
270 store i16 %b, i16* %a, align 4
274 define void @test_store32(i32* %a, i32 %b) sanitize_hwaddress {
275 ; CHECK-LABEL: @test_store32(
276 ; RECOVER: %[[A:[^ ]*]] = ptrtoint i32* %a to i64
277 ; RECOVER: %[[B:[^ ]*]] = lshr i64 %[[A]], 56
278 ; RECOVER: %[[PTRTAG:[^ ]*]] = trunc i64 %[[B]] to i8
279 ; RECOVER: %[[C:[^ ]*]] = and i64 %[[A]], 72057594037927935
280 ; RECOVER: %[[D:[^ ]*]] = lshr i64 %[[C]], 4
281 ; RECOVER-DYNAMIC-SHADOW: %[[E:[^ ]*]] = getelementptr i8, i8* %.hwasan.shadow, i64 %4
282 ; RECOVER-ZERO-BASED-SHADOW: %[[E:[^ ]*]] = inttoptr i64 %[[D]] to i8*
283 ; RECOVER: %[[MEMTAG:[^ ]*]] = load i8, i8* %[[E]]
284 ; RECOVER: %[[F:[^ ]*]] = icmp ne i8 %[[PTRTAG]], %[[MEMTAG]]
285 ; RECOVER: br i1 %[[F]], label {{.*}}, label {{.*}}, !prof {{.*}}
287 ; RECOVER: call void asm sideeffect "brk #2354", "{x0}"(i64 %[[A]])
290 ; ABORT: %[[A:[^ ]*]] = bitcast i32* %a to i8*
291 ; ABORT-DYNAMIC-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* %.hwasan.shadow, i8* %[[A]], i32 18)
292 ; ABORT-ZERO-BASED-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* null, i8* %[[A]], i32 18)
294 ; CHECK: store i32 %b, i32* %a, align 4
298 store i32 %b, i32* %a, align 4
302 define void @test_store64(i64* %a, i64 %b) sanitize_hwaddress {
303 ; CHECK-LABEL: @test_store64(
304 ; RECOVER: %[[A:[^ ]*]] = ptrtoint i64* %a to i64
305 ; RECOVER: %[[B:[^ ]*]] = lshr i64 %[[A]], 56
306 ; RECOVER: %[[PTRTAG:[^ ]*]] = trunc i64 %[[B]] to i8
307 ; RECOVER: %[[C:[^ ]*]] = and i64 %[[A]], 72057594037927935
308 ; RECOVER: %[[D:[^ ]*]] = lshr i64 %[[C]], 4
309 ; RECOVER-DYNAMIC-SHADOW: %[[E:[^ ]*]] = getelementptr i8, i8* %.hwasan.shadow, i64 %4
310 ; RECOVER-ZERO-BASED-SHADOW: %[[E:[^ ]*]] = inttoptr i64 %[[D]] to i8*
311 ; RECOVER: %[[MEMTAG:[^ ]*]] = load i8, i8* %[[E]]
312 ; RECOVER: %[[F:[^ ]*]] = icmp ne i8 %[[PTRTAG]], %[[MEMTAG]]
313 ; RECOVER: br i1 %[[F]], label {{.*}}, label {{.*}}, !prof {{.*}}
315 ; RECOVER: call void asm sideeffect "brk #2355", "{x0}"(i64 %[[A]])
318 ; ABORT: %[[A:[^ ]*]] = bitcast i64* %a to i8*
319 ; ABORT-DYNAMIC-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* %.hwasan.shadow, i8* %[[A]], i32 19)
320 ; ABORT-ZERO-BASED-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* null, i8* %[[A]], i32 19)
322 ; CHECK: store i64 %b, i64* %a, align 8
326 store i64 %b, i64* %a, align 8
330 define void @test_store128(i128* %a, i128 %b) sanitize_hwaddress {
331 ; CHECK-LABEL: @test_store128(
332 ; RECOVER: %[[A:[^ ]*]] = ptrtoint i128* %a to i64
333 ; RECOVER: %[[B:[^ ]*]] = lshr i64 %[[A]], 56
334 ; RECOVER: %[[PTRTAG:[^ ]*]] = trunc i64 %[[B]] to i8
335 ; RECOVER: %[[C:[^ ]*]] = and i64 %[[A]], 72057594037927935
336 ; RECOVER: %[[D:[^ ]*]] = lshr i64 %[[C]], 4
337 ; RECOVER-DYNAMIC-SHADOW: %[[E:[^ ]*]] = getelementptr i8, i8* %.hwasan.shadow, i64 %4
338 ; RECOVER-ZERO-BASED-SHADOW: %[[E:[^ ]*]] = inttoptr i64 %[[D]] to i8*
339 ; RECOVER: %[[MEMTAG:[^ ]*]] = load i8, i8* %[[E]]
340 ; RECOVER: %[[F:[^ ]*]] = icmp ne i8 %[[PTRTAG]], %[[MEMTAG]]
341 ; RECOVER: br i1 %[[F]], label {{.*}}, label {{.*}}, !prof {{.*}}
343 ; RECOVER: call void asm sideeffect "brk #2356", "{x0}"(i64 %[[A]])
346 ; ABORT: %[[A:[^ ]*]] = bitcast i128* %a to i8*
347 ; ABORT-DYNAMIC-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* %.hwasan.shadow, i8* %[[A]], i32 20)
348 ; ABORT-ZERO-BASED-SHADOW: call void @llvm.hwasan.check.memaccess.shortgranules(i8* null, i8* %[[A]], i32 20)
350 ; CHECK: store i128 %b, i128* %a, align 16
354 store i128 %b, i128* %a, align 16
358 define void @test_store40(i40* %a, i40 %b) sanitize_hwaddress {
359 ; CHECK-LABEL: @test_store40(
360 ; CHECK: %[[A:[^ ]*]] = ptrtoint i40* %a to i64
361 ; ABORT: call void @__hwasan_storeN(i64 %[[A]], i64 5)
362 ; RECOVER: call void @__hwasan_storeN_noabort(i64 %[[A]], i64 5)
363 ; CHECK: store i40 %b, i40* %a
367 store i40 %b, i40* %a, align 4
371 define void @test_store_unaligned(i64* %a, i64 %b) sanitize_hwaddress {
372 ; CHECK-LABEL: @test_store_unaligned(
373 ; CHECK: %[[A:[^ ]*]] = ptrtoint i64* %a to i64
374 ; ABORT: call void @__hwasan_storeN(i64 %[[A]], i64 8)
375 ; RECOVER: call void @__hwasan_storeN_noabort(i64 %[[A]], i64 8)
376 ; CHECK: store i64 %b, i64* %a, align 4
380 store i64 %b, i64* %a, align 4
384 define i8 @test_load_noattr(i8* %a) {
385 ; CHECK-LABEL: @test_load_noattr(
387 ; CHECK-NEXT: %[[B:[^ ]*]] = load i8, i8* %a
388 ; CHECK-NEXT: ret i8 %[[B]]
391 %b = load i8, i8* %a, align 4
395 define i8 @test_load_notmyattr(i8* %a) sanitize_address {
396 ; CHECK-LABEL: @test_load_notmyattr(
398 ; CHECK-NEXT: %[[B:[^ ]*]] = load i8, i8* %a
399 ; CHECK-NEXT: ret i8 %[[B]]
402 %b = load i8, i8* %a, align 4
406 define i8 @test_load_addrspace(i8 addrspace(256)* %a) sanitize_hwaddress {
407 ; CHECK-LABEL: @test_load_addrspace(
409 ; CHECK-NEXT: %[[B:[^ ]*]] = load i8, i8 addrspace(256)* %a
410 ; CHECK-NEXT: ret i8 %[[B]]
413 %b = load i8, i8 addrspace(256)* %a, align 4
417 ; CHECK: declare void @__hwasan_init()
419 ; CHECK: define internal void @hwasan.module_ctor() comdat {
420 ; CHECK-NEXT: call void @__hwasan_init()
421 ; CHECK-NEXT: ret void