[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / llvm / test / Instrumentation / HWAddressSanitizer / X86 / basic.ll
blob59e73c5f208195bb41d82ac30f5a508723785f0e
1 ; Test basic address sanitizer instrumentation.
2 ; Generic code is covered by ../basic.ll, only the x86_64 specific code is
3 ; tested here.
5 ; RUN: opt < %s -hwasan -hwasan-recover=0 -S | FileCheck %s  --check-prefixes=CHECK,ABORT
6 ; RUN: opt < %s -hwasan -hwasan-recover=1 -S | FileCheck %s  --check-prefixes=CHECK,RECOVER
8 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
9 target triple = "x86_64-unknown-linux-gnu"
11 define i8 @test_load8(i8* %a) sanitize_hwaddress {
12 ; CHECK-LABEL: @test_load8(
13 ; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %a to i64
15 ; ABORT: call void @__hwasan_load1(i64 %[[A]])
16 ; RECOVER: call void @__hwasan_load1_noabort(i64 %[[A]])
18 ; CHECK: %[[G:[^ ]*]] = load i8, i8* %a, align 4
19 ; CHECK: ret i8 %[[G]]
21 entry:
22   %b = load i8, i8* %a, align 4
23   ret i8 %b
26 define i40 @test_load40(i40* %a) sanitize_hwaddress {
27 ; CHECK-LABEL: @test_load40(
28 ; CHECK: %[[A:[^ ]*]] = ptrtoint i40* %a to i64
30 ; ABORT: call void @__hwasan_loadN(i64 %[[A]], i64 5)
31 ; RECOVER: call void @__hwasan_loadN_noabort(i64 %[[A]], i64 5)
33 ; CHECK: %[[B:[^ ]*]] = load i40, i40* %a
34 ; CHECK: ret i40 %[[B]]
36 entry:
37   %b = load i40, i40* %a, align 4
38   ret i40 %b
41 define void @test_store8(i8* %a, i8 %b) sanitize_hwaddress {
42 ; CHECK-LABEL: @test_store8(
43 ; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %a to i64
45 ; ABORT: call void @__hwasan_store1(i64 %[[A]])
46 ; RECOVER: call void @__hwasan_store1_noabort(i64 %[[A]])
48 ; CHECK: store i8 %b, i8* %a, align 4
49 ; CHECK: ret void
51 entry:
52   store i8 %b, i8* %a, align 4
53   ret void
56 define void @test_store40(i40* %a, i40 %b) sanitize_hwaddress {
57 ; CHECK-LABEL: @test_store40(
58 ; CHECK: %[[A:[^ ]*]] = ptrtoint i40* %a to i64
60 ; ABORT: call void @__hwasan_storeN(i64 %[[A]], i64 5)
61 ; RECOVER: call void @__hwasan_storeN_noabort(i64 %[[A]], i64 5)
63 ; CHECK: store i40 %b, i40* %a
64 ; CHECK: ret void
66 entry:
67   store i40 %b, i40* %a, align 4
68   ret void
71 define void @test_store_unaligned(i64* %a, i64 %b) sanitize_hwaddress {
72 ; CHECK-LABEL: @test_store_unaligned(
73 ; CHECK: %[[A:[^ ]*]] = ptrtoint i64* %a to i64
75 ; ABORT: call void @__hwasan_storeN(i64 %[[A]], i64 8)
76 ; RECOVER: call void @__hwasan_storeN_noabort(i64 %[[A]], i64 8)
78 ; CHECK: store i64 %b, i64* %a, align 4
79 ; CHECK: ret void
81 entry:
82   store i64 %b, i64* %a, align 4
83   ret void