1; RUN: opt < %s -asan -asan-module -S | FileCheck --check-prefixes=CHECK,CHECK-S3 %s
2; RUN: opt < %s -asan -asan-module -asan-mapping-scale=5 -S | FileCheck --check-prefixes=CHECK,CHECK-S5 %s
3target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
4target triple = "x86_64-unknown-linux-gnu"
5define i32 @read_4_bytes(i32* %a) sanitize_address {
6entry:
7  %tmp1 = load i32, i32* %a, align 4
8  ret i32 %tmp1
9}
10; CHECK-LABEL: @read_4_bytes
11; CHECK-NOT: ret
12; CHECK-S3: lshr {{.*}} 3
13; CHECK-S5: lshr {{.*}} 5
14; Check for ASAN's Offset for 64-bit (7fff8000|7ffe0000)
15; CHECK-S3-NEXT: add{{.*}}2147450880
16; CHECK-S5-NEXT: add{{.*}}2147352576
17; CHECK: ret
18
19define void @example_atomicrmw(i64* %ptr) nounwind uwtable sanitize_address {
20entry:
21  %0 = atomicrmw add i64* %ptr, i64 1 seq_cst
22  ret void
23}
24
25; CHECK-LABEL: @example_atomicrmw
26; CHECK-S3: lshr {{.*}} 3
27; CHECK-S5: lshr {{.*}} 5
28; CHECK: __asan_report_store8
29; CHECK-NOT: __asan_report
30; CHECK: atomicrmw
31; CHECK: ret
32
33define void @example_cmpxchg(i64* %ptr, i64 %compare_to, i64 %new_value) nounwind uwtable sanitize_address {
34entry:
35  %0 = cmpxchg i64* %ptr, i64 %compare_to, i64 %new_value seq_cst seq_cst
36  ret void
37}
38
39; CHECK-LABEL: @example_cmpxchg
40; CHECK-S3: lshr {{.*}} 3
41; CHECK-S5: lshr {{.*}} 5
42; CHECK: __asan_report_store8
43; CHECK-NOT: __asan_report
44; CHECK: cmpxchg
45; CHECK: ret
46