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