1 ; Test basic address sanitizer instrumentation for Myriad.
3 ; RUN: opt -asan -asan-module -S < %s | FileCheck %s
5 target triple = "sparc-myriad-rtems"
6 target datalayout = "E-m:e-p:32:32-i64:64-f128:64-n32-S64"
7 ; CHECK: @llvm.global_ctors = {{.*}}@asan.module_ctor
9 define i32 @test_load(i32* %a) sanitize_address {
10 ; CHECK-LABEL: @test_load
12 ; CHECK: ptrtoint i32* %a to i32
13 ; CHECK: %[[LOAD_ADDR:[^ ]*]] = and i32 %{{.*}}, -1073741825
14 ; CHECK: lshr i32 %{{.*}}, 29
15 ; CHECK: icmp eq i32 %{{.*}}, 4
16 ; CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}!prof ![[PROF:[0-9]+]]
18 ; This block checks whether the shadow byte is 0.
19 ; CHECK: lshr i32 %[[LOAD_ADDR]], 5
20 ; CHECK: add i32 %{{.*}}, -1694498816
21 ; CHECK: %[[LOAD_SHADOW_PTR:[^ ]*]] = inttoptr
22 ; CHECK: %[[LOAD_SHADOW:[^ ]*]] = load i8, i8* %[[LOAD_SHADOW_PTR]]
24 ; CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}!prof ![[PROF:[0-9]+]]
26 ; This block refines the shadow test.
27 ; CHECK: and i32 %[[LOAD_ADDR]], 31
28 ; CHECK: add i32 %{{.*}}, 3
29 ; CHECK: trunc i32 %{{.*}} to i8
30 ; CHECK: icmp sge i8 %{{.*}}, %[[LOAD_SHADOW]]
31 ; CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}
33 ; The crash block reports the error.
34 ; CHECK: call void @__asan_report_load4(i32 %[[LOAD_ADDR]])
38 ; CHECK: %tmp1 = load i32, i32* %a
39 ; CHECK: ret i32 %tmp1
42 %tmp1 = load i32, i32* %a, align 4
46 define void @test_store(i32* %a) sanitize_address {
47 ; CHECK-LABEL: @test_store
49 ; CHECK: ptrtoint i32* %a to i32
50 ; CHECK: %[[STORE_ADDR:[^ ]*]] = and i32 %{{.*}}, -1073741825
51 ; CHECK: lshr i32 %{{.*}}, 29
52 ; CHECK: icmp eq i32 %{{.*}}, 4
53 ; CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}!prof ![[PROF:[0-9]+]]
55 ; This block checks whether the shadow byte is 0.
56 ; CHECK: lshr i32 %[[STORE_ADDR]], 5
57 ; CHECK: add i32 %{{.*}}, -1694498816
58 ; CHECK: %[[STORE_SHADOW_PTR:[^ ]*]] = inttoptr
59 ; CHECK: %[[STORE_SHADOW:[^ ]*]] = load i8, i8* %[[STORE_SHADOW_PTR]]
61 ; CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}
63 ; This block refines the shadow test.
64 ; CHECK: and i32 %[[STORE_ADDR]], 31
65 ; CHECK: add i32 %{{.*}}, 3
66 ; CHECK: trunc i32 %{{.*}} to i8
67 ; CHECK: icmp sge i8 %{{.*}}, %[[STORE_SHADOW]]
68 ; CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}
70 ; The crash block reports the error.
71 ; CHECK: call void @__asan_report_store4(i32 %[[STORE_ADDR]])
74 ; CHECK: store i32 42, i32* %a
79 store i32 42, i32* %a, align 4
83 ; CHECK: define internal void @asan.module_ctor()
84 ; CHECK: call void @__asan_init()