Debian Codegraph @

llvm/test/Instrumentation/HWAddressSanitizer/X86/with-calls.ll

raw
1 ; Test basic address sanitizer instrumentation.
2 ;
3 ; RUN: opt < %s -passes=hwasan -hwasan-instrument-with-calls -S | FileCheck %s --check-prefixes=CHECK,ABORT
4 ; RUN: opt < %s -passes=hwasan -hwasan-instrument-with-calls -hwasan-recover=1 -S | FileCheck %s --check-prefixes=CHECK,RECOVER
5
6 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
7 target triple = "x86_64-unknown-linux-gnu"
8
9 define i8 @test_load8(ptr %a) sanitize_hwaddress {
10 ; CHECK-LABEL: @test_load8(
11 ; CHECK: %[[A:[^ ]*]] = ptrtoint ptr %a to i64
12
13 ; ABORT: call void @__hwasan_load1(i64 %[[A]])
14 ; RECOVER: call void @__hwasan_load1_noabort(i64 %[[A]])
15
16 ; CHECK: %[[B:[^ ]*]] = load i8, ptr %a
17 ; CHECK: ret i8 %[[B]]
18
19 entry:
20 %b = load i8, ptr %a, align 4
21 ret i8 %b
22 }
23
24 define i40 @test_load40(ptr %a) sanitize_hwaddress {
25 ; CHECK-LABEL: @test_load40(
26 ; CHECK: %[[A:[^ ]*]] = ptrtoint ptr %a to i64
27
28 ; ABORT: call void @__hwasan_loadN(i64 %[[A]], i64 5)
29 ; RECOVER: call void @__hwasan_loadN_noabort(i64 %[[A]], i64 5)
30
31 ; CHECK: %[[B:[^ ]*]] = load i40, ptr %a
32 ; CHECK: ret i40 %[[B]]
33
34 entry:
35 %b = load i40, ptr %a, align 4
36 ret i40 %b
37 }
38
39 define void @test_store8(ptr %a, i8 %b) sanitize_hwaddress {
40 ; CHECK-LABEL: @test_store8(
41 ; CHECK: %[[A:[^ ]*]] = ptrtoint ptr %a to i64
42
43 ; ABORT: call void @__hwasan_store1(i64 %[[A]])
44 ; RECOVER: call void @__hwasan_store1_noabort(i64 %[[A]])
45
46 ; CHECK: store i8 %b, ptr %a
47 ; CHECK: ret void
48
49 entry:
50 store i8 %b, ptr %a, align 4
51 ret void
52 }
53
54 define void @test_store40(ptr %a, i40 %b) sanitize_hwaddress {
55 ; CHECK-LABEL: @test_store40(
56 ; CHECK: %[[A:[^ ]*]] = ptrtoint ptr %a to i64
57
58 ; ABORT: call void @__hwasan_storeN(i64 %[[A]], i64 5)
59 ; RECOVER: call void @__hwasan_storeN_noabort(i64 %[[A]], i64 5)
60
61 ; CHECK: store i40 %b, ptr %a
62 ; CHECK: ret void
63
64 entry:
65 store i40 %b, ptr %a, align 4
66 ret void
67 }