1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
3 ; RUN: opt < %s -passes=hwasan -S | FileCheck %s
4 ; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset-dynamic=global -S | FileCheck %s --check-prefixes=GLOBAL
5 ; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset=567 -S | FileCheck %s --check-prefixes=FIXED
6 ; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset=567 -hwasan-mapping-offset-dynamic=global -S | FileCheck %s --check-prefixes=FIXED-GLOBAL
7 ; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset-dynamic=global -hwasan-mapping-offset=567 -S | FileCheck %s --check-prefixes=GLOBAL-FIXED
9 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
10 target triple = "aarch64--linux-android"
12 define i8 @test_load8(ptr %a) sanitize_hwaddress {
13 ; CHECK-LABEL: define i8 @test_load8
14 ; CHECK-SAME: (ptr [[A:%.*]]) #[[ATTR0:[0-9]+]] {
15 ; CHECK-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr @__hwasan_shadow)
16 ; CHECK-NEXT: call void @llvm.hwasan.check.memaccess(ptr [[DOTHWASAN_SHADOW]], ptr [[A]], i32 0)
17 ; CHECK-NEXT: [[B:%.*]] = load i8, ptr [[A]], align 4
18 ; CHECK-NEXT: ret i8 [[B]]
20 ; GLOBAL-LABEL: define i8 @test_load8
21 ; GLOBAL-SAME: (ptr [[A:%.*]]) #[[ATTR0:[0-9]+]] {
22 ; GLOBAL-NEXT: [[TMP1:%.*]] = load ptr, ptr @__hwasan_shadow_memory_dynamic_address, align 8
23 ; GLOBAL-NEXT: call void @llvm.hwasan.check.memaccess(ptr [[TMP1]], ptr [[A]], i32 0)
24 ; GLOBAL-NEXT: [[B:%.*]] = load i8, ptr [[A]], align 4
25 ; GLOBAL-NEXT: ret i8 [[B]]
27 ; FIXED-LABEL: define i8 @test_load8
28 ; FIXED-SAME: (ptr [[A:%.*]]) #[[ATTR0:[0-9]+]] {
29 ; FIXED-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr inttoptr (i64 567 to ptr))
30 ; FIXED-NEXT: call void @llvm.hwasan.check.memaccess(ptr [[DOTHWASAN_SHADOW]], ptr [[A]], i32 0)
31 ; FIXED-NEXT: [[B:%.*]] = load i8, ptr [[A]], align 4
32 ; FIXED-NEXT: ret i8 [[B]]
34 ; FIXED-GLOBAL-LABEL: define i8 @test_load8
35 ; FIXED-GLOBAL-SAME: (ptr [[A:%.*]]) #[[ATTR0:[0-9]+]] {
36 ; FIXED-GLOBAL-NEXT: [[TMP1:%.*]] = load ptr, ptr @__hwasan_shadow_memory_dynamic_address, align 8
37 ; FIXED-GLOBAL-NEXT: call void @llvm.hwasan.check.memaccess(ptr [[TMP1]], ptr [[A]], i32 0)
38 ; FIXED-GLOBAL-NEXT: [[B:%.*]] = load i8, ptr [[A]], align 4
39 ; FIXED-GLOBAL-NEXT: ret i8 [[B]]
41 ; GLOBAL-FIXED-LABEL: define i8 @test_load8
42 ; GLOBAL-FIXED-SAME: (ptr [[A:%.*]]) #[[ATTR0:[0-9]+]] {
43 ; GLOBAL-FIXED-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr inttoptr (i64 567 to ptr))
44 ; GLOBAL-FIXED-NEXT: call void @llvm.hwasan.check.memaccess(ptr [[DOTHWASAN_SHADOW]], ptr [[A]], i32 0)
45 ; GLOBAL-FIXED-NEXT: [[B:%.*]] = load i8, ptr [[A]], align 4
46 ; GLOBAL-FIXED-NEXT: ret i8 [[B]]
48 %b = load i8, ptr %a, align 4