xref: /llvm-project/llvm/test/Instrumentation/HWAddressSanitizer/X86/kernel.ll (revision 6f3335f590ff080beffa090d7f2a783155974497)
1; Test KHWASan instrumentation.
2; Generic code is covered by ../kernel.ll, only the x86_64 specific code is
3; tested here.
4;
5; RUN: opt < %s -passes=hwasan -hwasan-kernel=1 -S | FileCheck %s --allow-empty --check-prefixes=INIT
6; RUN: opt < %s -passes=hwasan -hwasan-kernel=1 -S | FileCheck %s
7; RUN: opt < %s -passes=hwasan -hwasan-kernel=1 -hwasan-mapping-offset=12345678 -S | FileCheck %s
8; RUN: opt < %s -passes=hwasan -hwasan-kernel=1 -hwasan-recover=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT
9; RUN: opt < %s -passes=hwasan -hwasan-kernel=1 -hwasan-recover=1 -S | FileCheck %s --check-prefixes=CHECK,RECOVER
10
11target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
12target triple = "x86_64-unknown-linux-gnu"
13
14define i8 @test_load(ptr %a) sanitize_hwaddress {
15; CHECK-LABEL: @test_load(
16; CHECK: %[[A:[^ ]*]] = ptrtoint ptr %a to i64
17
18; ABORT: call void @__hwasan_load1(i64 %[[A]])
19; RECOVER: call void @__hwasan_load1_noabort(i64 %[[A]])
20
21; CHECK: %[[G:[^ ]*]] = load i8, ptr %a, align 4
22; CHECK: ret i8 %[[G]]
23
24entry:
25  %b = load i8, ptr %a, align 4
26  ret i8 %b
27}
28
29; INIT-NOT: call void @__hwasan_init
30