xref: /aosp_15_r20/external/llvm/test/Instrumentation/AddressSanitizer/test64.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -asan -asan-module -S | FileCheck %s
2*9880d681SAndroid Build Coastguard Workertarget 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"
3*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-unknown-linux-gnu"
4*9880d681SAndroid Build Coastguard Workerdefine i32 @read_4_bytes(i32* %a) sanitize_address {
5*9880d681SAndroid Build Coastguard Workerentry:
6*9880d681SAndroid Build Coastguard Worker  %tmp1 = load i32, i32* %a, align 4
7*9880d681SAndroid Build Coastguard Worker  ret i32 %tmp1
8*9880d681SAndroid Build Coastguard Worker}
9*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @read_4_bytes
10*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: ret
11*9880d681SAndroid Build Coastguard Worker; CHECK: lshr {{.*}} 3
12*9880d681SAndroid Build Coastguard Worker; Check for ASAN's Offset for 64-bit (7fff8000)
13*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: add{{.*}}2147450880
14*9880d681SAndroid Build Coastguard Worker; CHECK: ret
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Workerdefine void @example_atomicrmw(i64* %ptr) nounwind uwtable sanitize_address {
17*9880d681SAndroid Build Coastguard Workerentry:
18*9880d681SAndroid Build Coastguard Worker  %0 = atomicrmw add i64* %ptr, i64 1 seq_cst
19*9880d681SAndroid Build Coastguard Worker  ret void
20*9880d681SAndroid Build Coastguard Worker}
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @example_atomicrmw
23*9880d681SAndroid Build Coastguard Worker; CHECK: lshr {{.*}} 3
24*9880d681SAndroid Build Coastguard Worker; CHECK: __asan_report_store8
25*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: __asan_report
26*9880d681SAndroid Build Coastguard Worker; CHECK: atomicrmw
27*9880d681SAndroid Build Coastguard Worker; CHECK: ret
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Workerdefine void @example_cmpxchg(i64* %ptr, i64 %compare_to, i64 %new_value) nounwind uwtable sanitize_address {
30*9880d681SAndroid Build Coastguard Workerentry:
31*9880d681SAndroid Build Coastguard Worker  %0 = cmpxchg i64* %ptr, i64 %compare_to, i64 %new_value seq_cst seq_cst
32*9880d681SAndroid Build Coastguard Worker  ret void
33*9880d681SAndroid Build Coastguard Worker}
34*9880d681SAndroid Build Coastguard Worker
35*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @example_cmpxchg
36*9880d681SAndroid Build Coastguard Worker; CHECK: lshr {{.*}} 3
37*9880d681SAndroid Build Coastguard Worker; CHECK: __asan_report_store8
38*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: __asan_report
39*9880d681SAndroid Build Coastguard Worker; CHECK: cmpxchg
40*9880d681SAndroid Build Coastguard Worker; CHECK: ret
41