• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test that the scale (-asan-mapping-scale) and offset (-asan-mapping-offset) command-line options work as expected
2;
3; RUN: opt < %s -asan -asan-module -asan-mapping-offset 0xdeadbeef -S | FileCheck --check-prefix=CHECK-OFFSET %s
4; RUN: opt < %s -asan -asan-module -asan-mapping-scale 1 -S | FileCheck --check-prefix=CHECK-SCALE %s
5; RUN: opt < %s -asan -asan-module -asan-mapping-offset 0xc0ffee -asan-mapping-scale 0 -S | FileCheck --check-prefix=CHECK-BOTH %s
6target triple = "x86_64-unknown-linux-gnu"
7
8define i32 @read_offset(i32* %a) sanitize_address {
9entry:
10  %tmp1 = load i32, i32* %a, align 4
11  ret i32 %tmp1
12}
13; CHECK-OFFSET-LABEL: @read_offset
14; CHECK-OFFSET-NOT: ret
15; CHECK-OFFSET: lshr {{.*}} 3
16; CHECK-OFFSET-NEXT: add{{.*}}3735928559
17; CHECK-OFFSET: ret
18
19define i32 @read_scale(i32* %a) sanitize_address {
20entry:
21  %tmp1 = load i32, i32* %a, align 4
22  ret i32 %tmp1
23}
24; CHECK-SCALE-LABEL: @read_scale
25; CHECK-SCALE-NOT: ret
26; CHECK-SCALE: lshr {{.*}} 1
27; CHECK-SCALE-NEXT: add{{.*}}
28; CHECK-SCALE: ret
29
30define i32 @read_both(i32* %a) sanitize_address {
31entry:
32  %tmp1 = load i32, i32* %a, align 4
33  ret i32 %tmp1
34}
35; CHECK-BOTH-LABEL: @read_both
36; CHECK-BOTH-NOT: ret
37; CHECK-BOTH: lshr {{.*}} 0
38; CHECK-BOTH-NEXT: add{{.*}}12648430
39; CHECK-BOTH: ret
40