1 ; Test KHWASan instrumentation.
2 ; Generic code is covered by ../kernel.ll, only the x86_64 specific code is
5 ; RUN: opt < %s -hwasan -hwasan-kernel=1 -S | FileCheck %s --allow-empty --check-prefixes=INIT
6 ; RUN: opt < %s -hwasan -hwasan-kernel=1 -S | FileCheck %s
7 ; RUN: opt < %s -hwasan -hwasan-kernel=1 -hwasan-mapping-offset=12345678 -S | FileCheck %s
8 ; RUN: opt < %s -hwasan -hwasan-kernel=1 -hwasan-recover=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT
9 ; RUN: opt < %s -hwasan -hwasan-kernel=1 -hwasan-recover=1 -S | FileCheck %s --check-prefixes=CHECK,RECOVER
11 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
12 target triple = "x86_64-unknown-linux-gnu"
14 define i8 @test_load(i8* %a) sanitize_hwaddress {
15 ; CHECK-LABEL: @test_load(
16 ; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %a to i64
18 ; ABORT: call void asm sideeffect "int3\0Anopl 64(%rax)", "{rdi}"(i64 %[[A]])
20 ; RECOVER: call void asm sideeffect "int3\0Anopl 96(%rax)", "{rdi}"(i64 %[[A]])
23 ; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %a to i64
24 ; CHECK: %[[UNTAGGED:[^ ]*]] = or i64 %[[A]], -72057594037927936
25 ; CHECK: %[[UNTAGGED_PTR:[^ ]*]] = inttoptr i64 %[[UNTAGGED]] to i8*
26 ; CHECK: %[[G:[^ ]*]] = load i8, i8* %[[UNTAGGED_PTR]], align 4
27 ; CHECK: ret i8 %[[G]]
30 %b = load i8, i8* %a, align 4
34 ; INIT-NOT: call void @__hwasan_init