xref: /llvm-project/llvm/test/CodeGen/X86/asan-check-memaccess-add.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s | FileCheck %s
3
4target triple = "x86_64-unknown-linux-gnu"
5
6define void @load1(ptr nocapture readonly %x) {
7; CHECK-LABEL: load1:
8; CHECK:       # %bb.0:
9; CHECK-NEXT:    pushq %rax
10; CHECK-NEXT:    .cfi_def_cfa_offset 16
11; CHECK-NEXT:    callq __asan_check_load_add_1_RDI
12; CHECK-NEXT:    callq __asan_check_store_add_1_RDI
13; CHECK-NEXT:    popq %rax
14; CHECK-NEXT:    .cfi_def_cfa_offset 8
15; CHECK-NEXT:    retq
16  call void @llvm.asan.check.memaccess(ptr %x, i32 0)
17  call void @llvm.asan.check.memaccess(ptr %x, i32 32)
18  ret void
19}
20
21define void @load2(ptr nocapture readonly %x) nounwind {
22; CHECK-LABEL: load2:
23; CHECK:       # %bb.0:
24; CHECK-NEXT:    pushq %rax
25; CHECK-NEXT:    callq __asan_check_load_add_2_RDI
26; CHECK-NEXT:    callq __asan_check_store_add_2_RDI
27; CHECK-NEXT:    popq %rax
28; CHECK-NEXT:    retq
29  %1 = ptrtoint ptr %x to i64
30  call void @llvm.asan.check.memaccess(ptr %x, i32 2)
31  call void @llvm.asan.check.memaccess(ptr %x, i32 34)
32  ret void
33}
34
35define void @load4(ptr nocapture readonly %x) nounwind {
36; CHECK-LABEL: load4:
37; CHECK:       # %bb.0:
38; CHECK-NEXT:    pushq %rax
39; CHECK-NEXT:    callq __asan_check_load_add_4_RDI
40; CHECK-NEXT:    callq __asan_check_store_add_4_RDI
41; CHECK-NEXT:    popq %rax
42; CHECK-NEXT:    retq
43  %1 = ptrtoint ptr %x to i64
44  call void @llvm.asan.check.memaccess(ptr %x, i32 4)
45  call void @llvm.asan.check.memaccess(ptr %x, i32 36)
46  ret void
47}
48
49define void @load8(ptr nocapture readonly %x) nounwind {
50; CHECK-LABEL: load8:
51; CHECK:       # %bb.0:
52; CHECK-NEXT:    pushq %rax
53; CHECK-NEXT:    callq __asan_check_load_add_8_RDI
54; CHECK-NEXT:    callq __asan_check_store_add_8_RDI
55; CHECK-NEXT:    popq %rax
56; CHECK-NEXT:    retq
57  %1 = ptrtoint ptr %x to i64
58  call void @llvm.asan.check.memaccess(ptr %x, i32 6)
59  call void @llvm.asan.check.memaccess(ptr %x, i32 38)
60  ret void
61}
62
63define void @load16(ptr nocapture readonly %x) nounwind {
64; CHECK-LABEL: load16:
65; CHECK:       # %bb.0:
66; CHECK-NEXT:    pushq %rax
67; CHECK-NEXT:    callq __asan_check_load_add_16_RDI
68; CHECK-NEXT:    callq __asan_check_store_add_16_RDI
69; CHECK-NEXT:    popq %rax
70; CHECK-NEXT:    retq
71  %1 = ptrtoint ptr %x to i64
72  call void @llvm.asan.check.memaccess(ptr %x, i32 8)
73  call void @llvm.asan.check.memaccess(ptr %x, i32 40)
74  ret void
75}
76
77declare void @llvm.asan.check.memaccess(ptr, i32 immarg)
78