1 ; Test basic address sanitizer instrumentation.
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
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"
9 define i8 @test_load8(ptr %a) sanitize_hwaddress {
10 ; CHECK-LABEL: @test_load8(
11 ; CHECK: %[[A:[^ ]*]] = ptrtoint ptr %a to i64
13 ; ABORT: call void @__hwasan_load1(i64 %[[A]])
14 ; RECOVER: call void @__hwasan_load1_noabort(i64 %[[A]])
16 ; CHECK: %[[B:[^ ]*]] = load i8, ptr %a
17 ; CHECK: ret i8 %[[B]]
20 %b = load i8, ptr %a, align 4
24 define i40 @test_load40(ptr %a) sanitize_hwaddress {
25 ; CHECK-LABEL: @test_load40(
26 ; CHECK: %[[A:[^ ]*]] = ptrtoint ptr %a to i64
28 ; ABORT: call void @__hwasan_loadN(i64 %[[A]], i64 5)
29 ; RECOVER: call void @__hwasan_loadN_noabort(i64 %[[A]], i64 5)
31 ; CHECK: %[[B:[^ ]*]] = load i40, ptr %a
32 ; CHECK: ret i40 %[[B]]
35 %b = load i40, ptr %a, align 4
39 define void @test_store8(ptr %a, i8 %b) sanitize_hwaddress {
40 ; CHECK-LABEL: @test_store8(
41 ; CHECK: %[[A:[^ ]*]] = ptrtoint ptr %a to i64
43 ; ABORT: call void @__hwasan_store1(i64 %[[A]])
44 ; RECOVER: call void @__hwasan_store1_noabort(i64 %[[A]])
46 ; CHECK: store i8 %b, ptr %a
50 store i8 %b, ptr %a, align 4
54 define void @test_store40(ptr %a, i40 %b) sanitize_hwaddress {
55 ; CHECK-LABEL: @test_store40(
56 ; CHECK: %[[A:[^ ]*]] = ptrtoint ptr %a to i64
58 ; ABORT: call void @__hwasan_storeN(i64 %[[A]], i64 5)
59 ; RECOVER: call void @__hwasan_storeN_noabort(i64 %[[A]], i64 5)
61 ; CHECK: store i40 %b, ptr %a
65 store i40 %b, ptr %a, align 4