[llvm] 5f5fb66 - [NFC][hwasan] Precommit X86 inline tests
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 26 23:30:15 PDT 2023
Author: Vitaly Buka
Date: 2023-04-26T23:30:01-07:00
New Revision: 5f5fb66a3bda4ba6a1c85f7f534c311b5a1552c9
URL: https://github.com/llvm/llvm-project/commit/5f5fb66a3bda4ba6a1c85f7f534c311b5a1552c9
DIFF: https://github.com/llvm/llvm-project/commit/5f5fb66a3bda4ba6a1c85f7f534c311b5a1552c9.diff
LOG: [NFC][hwasan] Precommit X86 inline tests
-hwasan-instrument-with-calls is broken on X86.
Added:
Modified:
llvm/test/Instrumentation/HWAddressSanitizer/X86/alloca.ll
llvm/test/Instrumentation/HWAddressSanitizer/X86/basic.ll
Removed:
################################################################################
diff --git a/llvm/test/Instrumentation/HWAddressSanitizer/X86/alloca.ll b/llvm/test/Instrumentation/HWAddressSanitizer/X86/alloca.ll
index 21c1ec49d1a1..20a3242de5fa 100644
--- a/llvm/test/Instrumentation/HWAddressSanitizer/X86/alloca.ll
+++ b/llvm/test/Instrumentation/HWAddressSanitizer/X86/alloca.ll
@@ -1,7 +1,8 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
; Test alloca instrumentation.
;
-; RUN: opt < %s -passes=hwasan -S | FileCheck %s
+; RUN: opt < %s -passes=hwasan -hwasan-use-stack-safety=0 -S | FileCheck %s
+; RUN: opt < %s -passes=hwasan -hwasan-use-stack-safety=0 -hwasan-instrument-with-calls=0 -S | FileCheck %s --check-prefixes=INLINE
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@@ -33,8 +34,100 @@ define void @test_alloca() sanitize_hwaddress {
; CHECK-NEXT: call void @__hwasan_tag_memory(ptr [[X]], i8 [[TMP10]], i64 16)
; CHECK-NEXT: ret void
;
+; INLINE-LABEL: define void @test_alloca
+; INLINE-SAME: () #[[ATTR0:[0-9]+]] personality ptr @__hwasan_personality_thunk {
+; INLINE-NEXT: entry:
+; INLINE-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
+; INLINE-NEXT: [[TMP0:%.*]] = call ptr @llvm.frameaddress.p0(i32 0)
+; INLINE-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64
+; INLINE-NEXT: [[TMP2:%.*]] = lshr i64 [[TMP1]], 20
+; INLINE-NEXT: [[TMP3:%.*]] = xor i64 [[TMP1]], [[TMP2]]
+; INLINE-NEXT: [[HWASAN_STACK_BASE_TAG:%.*]] = and i64 [[TMP3]], 63
+; INLINE-NEXT: [[TMP4:%.*]] = lshr i64 [[TMP1]], 57
+; INLINE-NEXT: [[HWASAN_UAR_TAG:%.*]] = and i64 [[TMP4]], 63
+; INLINE-NEXT: [[X:%.*]] = alloca { i32, [12 x i8] }, align 16
+; INLINE-NEXT: [[TMP5:%.*]] = xor i64 [[HWASAN_STACK_BASE_TAG]], 0
+; INLINE-NEXT: [[TMP6:%.*]] = ptrtoint ptr [[X]] to i64
+; INLINE-NEXT: [[TMP7:%.*]] = shl i64 [[TMP5]], 57
+; INLINE-NEXT: [[TMP8:%.*]] = or i64 [[TMP6]], [[TMP7]]
+; INLINE-NEXT: [[X_HWASAN:%.*]] = inttoptr i64 [[TMP8]] to ptr
+; INLINE-NEXT: [[TMP9:%.*]] = trunc i64 [[TMP5]] to i8
+; INLINE-NEXT: call void @__hwasan_tag_memory(ptr [[X]], i8 [[TMP9]], i64 16)
+; INLINE-NEXT: call void @use32(ptr nonnull [[X_HWASAN]])
+; INLINE-NEXT: [[TMP10:%.*]] = trunc i64 [[HWASAN_UAR_TAG]] to i8
+; INLINE-NEXT: call void @__hwasan_tag_memory(ptr [[X]], i8 [[TMP10]], i64 16)
+; INLINE-NEXT: ret void
+;
entry:
%x = alloca i32, align 4
call void @use32(ptr nonnull %x)
ret void
}
+
+
+define i32 @test_simple(ptr %a) sanitize_hwaddress {
+; CHECK-LABEL: define i32 @test_simple
+; CHECK-SAME: (ptr [[A:%.*]]) #[[ATTR0]] personality ptr @__hwasan_personality_thunk {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
+; CHECK-NEXT: [[TMP0:%.*]] = call ptr @llvm.frameaddress.p0(i32 0)
+; CHECK-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64
+; CHECK-NEXT: [[TMP2:%.*]] = lshr i64 [[TMP1]], 20
+; CHECK-NEXT: [[TMP3:%.*]] = xor i64 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: [[HWASAN_STACK_BASE_TAG:%.*]] = and i64 [[TMP3]], 63
+; CHECK-NEXT: [[TMP4:%.*]] = lshr i64 [[TMP1]], 57
+; CHECK-NEXT: [[HWASAN_UAR_TAG:%.*]] = and i64 [[TMP4]], 63
+; CHECK-NEXT: [[BUF_SROA_0:%.*]] = alloca { i8, [15 x i8] }, align 16
+; CHECK-NEXT: [[TMP5:%.*]] = xor i64 [[HWASAN_STACK_BASE_TAG]], 0
+; CHECK-NEXT: [[TMP6:%.*]] = ptrtoint ptr [[BUF_SROA_0]] to i64
+; CHECK-NEXT: [[TMP7:%.*]] = shl i64 [[TMP5]], 57
+; CHECK-NEXT: [[TMP8:%.*]] = or i64 [[TMP6]], [[TMP7]]
+; CHECK-NEXT: [[BUF_SROA_0_HWASAN:%.*]] = inttoptr i64 [[TMP8]] to ptr
+; CHECK-NEXT: [[TMP9:%.*]] = trunc i64 [[TMP5]] to i8
+; CHECK-NEXT: call void @__hwasan_tag_memory(ptr [[BUF_SROA_0]], i8 [[TMP9]], i64 16)
+; CHECK-NEXT: [[TMP10:%.*]] = ptrtoint ptr [[BUF_SROA_0_HWASAN]] to i64
+; CHECK-NEXT: call void @__hwasan_store1(i64 [[TMP10]])
+; CHECK-NEXT: store volatile i8 0, ptr [[BUF_SROA_0_HWASAN]], align 4
+; CHECK-NEXT: [[TMP11:%.*]] = trunc i64 [[HWASAN_UAR_TAG]] to i8
+; CHECK-NEXT: call void @__hwasan_tag_memory(ptr [[BUF_SROA_0]], i8 [[TMP11]], i64 16)
+; CHECK-NEXT: ret i32 0
+;
+; INLINE-LABEL: define i32 @test_simple
+; INLINE-SAME: (ptr [[A:%.*]]) #[[ATTR0]] personality ptr @__hwasan_personality_thunk {
+; INLINE-NEXT: entry:
+; INLINE-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
+; INLINE-NEXT: [[TMP0:%.*]] = call ptr @llvm.frameaddress.p0(i32 0)
+; INLINE-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64
+; INLINE-NEXT: [[TMP2:%.*]] = lshr i64 [[TMP1]], 20
+; INLINE-NEXT: [[TMP3:%.*]] = xor i64 [[TMP1]], [[TMP2]]
+; INLINE-NEXT: [[HWASAN_STACK_BASE_TAG:%.*]] = and i64 [[TMP3]], 63
+; INLINE-NEXT: [[TMP4:%.*]] = lshr i64 [[TMP1]], 57
+; INLINE-NEXT: [[HWASAN_UAR_TAG:%.*]] = and i64 [[TMP4]], 63
+; INLINE-NEXT: [[BUF_SROA_0:%.*]] = alloca { i8, [15 x i8] }, align 16
+; INLINE-NEXT: [[TMP5:%.*]] = xor i64 [[HWASAN_STACK_BASE_TAG]], 0
+; INLINE-NEXT: [[TMP6:%.*]] = ptrtoint ptr [[BUF_SROA_0]] to i64
+; INLINE-NEXT: [[TMP7:%.*]] = shl i64 [[TMP5]], 57
+; INLINE-NEXT: [[TMP8:%.*]] = or i64 [[TMP6]], [[TMP7]]
+; INLINE-NEXT: [[BUF_SROA_0_HWASAN:%.*]] = inttoptr i64 [[TMP8]] to ptr
+; INLINE-NEXT: [[TMP9:%.*]] = trunc i64 [[TMP5]] to i8
+; INLINE-NEXT: call void @__hwasan_tag_memory(ptr [[BUF_SROA_0]], i8 [[TMP9]], i64 16)
+; INLINE-NEXT: [[TMP10:%.*]] = ptrtoint ptr [[BUF_SROA_0_HWASAN]] to i64
+; INLINE-NEXT: call void @__hwasan_store1(i64 [[TMP10]])
+; INLINE-NEXT: store volatile i8 0, ptr [[BUF_SROA_0_HWASAN]], align 4
+; INLINE-NEXT: [[TMP11:%.*]] = trunc i64 [[HWASAN_UAR_TAG]] to i8
+; INLINE-NEXT: call void @__hwasan_tag_memory(ptr [[BUF_SROA_0]], i8 [[TMP11]], i64 16)
+; INLINE-NEXT: ret i32 0
+;
+entry:
+ %buf.sroa.0 = alloca i8, align 4
+ call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %buf.sroa.0)
+ store volatile i8 0, ptr %buf.sroa.0, align 4
+ call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %buf.sroa.0)
+ ret i32 0
+}
+
+; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
+declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
+
+; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
+declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
diff --git a/llvm/test/Instrumentation/HWAddressSanitizer/X86/basic.ll b/llvm/test/Instrumentation/HWAddressSanitizer/X86/basic.ll
index e1bc36c35741..47bd257776e2 100644
--- a/llvm/test/Instrumentation/HWAddressSanitizer/X86/basic.ll
+++ b/llvm/test/Instrumentation/HWAddressSanitizer/X86/basic.ll
@@ -5,6 +5,8 @@
;
; RUN: opt < %s -passes=hwasan -hwasan-recover=0 -S | FileCheck %s --check-prefixes=ABORT
; RUN: opt < %s -passes=hwasan -hwasan-recover=1 -S | FileCheck %s --check-prefixes=RECOVER
+; RUN: opt < %s -passes=hwasan -hwasan-recover=0 -hwasan-instrument-with-calls=0 -S | FileCheck %s --check-prefixes=ABORT-INLINE
+; RUN: opt < %s -passes=hwasan -hwasan-recover=1 -hwasan-instrument-with-calls=0 -S | FileCheck %s --check-prefixes=RECOVER-INLINE
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@@ -28,6 +30,24 @@ define i8 @test_load8(ptr %a) sanitize_hwaddress {
; RECOVER-NEXT: [[B:%.*]] = load i8, ptr [[A]], align 4
; RECOVER-NEXT: ret i8 [[B]]
;
+; ABORT-INLINE-LABEL: define i8 @test_load8
+; ABORT-INLINE-SAME: (ptr [[A:%.*]]) #[[ATTR0:[0-9]+]] {
+; ABORT-INLINE-NEXT: entry:
+; ABORT-INLINE-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
+; ABORT-INLINE-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
+; ABORT-INLINE-NEXT: call void @__hwasan_load1(i64 [[TMP0]])
+; ABORT-INLINE-NEXT: [[B:%.*]] = load i8, ptr [[A]], align 4
+; ABORT-INLINE-NEXT: ret i8 [[B]]
+;
+; RECOVER-INLINE-LABEL: define i8 @test_load8
+; RECOVER-INLINE-SAME: (ptr [[A:%.*]]) #[[ATTR0:[0-9]+]] {
+; RECOVER-INLINE-NEXT: entry:
+; RECOVER-INLINE-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
+; RECOVER-INLINE-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
+; RECOVER-INLINE-NEXT: call void @__hwasan_load1_noabort(i64 [[TMP0]])
+; RECOVER-INLINE-NEXT: [[B:%.*]] = load i8, ptr [[A]], align 4
+; RECOVER-INLINE-NEXT: ret i8 [[B]]
+;
@@ -55,6 +75,24 @@ define i40 @test_load40(ptr %a) sanitize_hwaddress {
; RECOVER-NEXT: [[B:%.*]] = load i40, ptr [[A]], align 4
; RECOVER-NEXT: ret i40 [[B]]
;
+; ABORT-INLINE-LABEL: define i40 @test_load40
+; ABORT-INLINE-SAME: (ptr [[A:%.*]]) #[[ATTR0]] {
+; ABORT-INLINE-NEXT: entry:
+; ABORT-INLINE-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
+; ABORT-INLINE-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
+; ABORT-INLINE-NEXT: call void @__hwasan_loadN(i64 [[TMP0]], i64 5)
+; ABORT-INLINE-NEXT: [[B:%.*]] = load i40, ptr [[A]], align 4
+; ABORT-INLINE-NEXT: ret i40 [[B]]
+;
+; RECOVER-INLINE-LABEL: define i40 @test_load40
+; RECOVER-INLINE-SAME: (ptr [[A:%.*]]) #[[ATTR0]] {
+; RECOVER-INLINE-NEXT: entry:
+; RECOVER-INLINE-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
+; RECOVER-INLINE-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
+; RECOVER-INLINE-NEXT: call void @__hwasan_loadN_noabort(i64 [[TMP0]], i64 5)
+; RECOVER-INLINE-NEXT: [[B:%.*]] = load i40, ptr [[A]], align 4
+; RECOVER-INLINE-NEXT: ret i40 [[B]]
+;
@@ -82,6 +120,24 @@ define void @test_store8(ptr %a, i8 %b) sanitize_hwaddress {
; RECOVER-NEXT: store i8 [[B]], ptr [[A]], align 4
; RECOVER-NEXT: ret void
;
+; ABORT-INLINE-LABEL: define void @test_store8
+; ABORT-INLINE-SAME: (ptr [[A:%.*]], i8 [[B:%.*]]) #[[ATTR0]] {
+; ABORT-INLINE-NEXT: entry:
+; ABORT-INLINE-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
+; ABORT-INLINE-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
+; ABORT-INLINE-NEXT: call void @__hwasan_store1(i64 [[TMP0]])
+; ABORT-INLINE-NEXT: store i8 [[B]], ptr [[A]], align 4
+; ABORT-INLINE-NEXT: ret void
+;
+; RECOVER-INLINE-LABEL: define void @test_store8
+; RECOVER-INLINE-SAME: (ptr [[A:%.*]], i8 [[B:%.*]]) #[[ATTR0]] {
+; RECOVER-INLINE-NEXT: entry:
+; RECOVER-INLINE-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
+; RECOVER-INLINE-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
+; RECOVER-INLINE-NEXT: call void @__hwasan_store1_noabort(i64 [[TMP0]])
+; RECOVER-INLINE-NEXT: store i8 [[B]], ptr [[A]], align 4
+; RECOVER-INLINE-NEXT: ret void
+;
@@ -109,6 +165,24 @@ define void @test_store40(ptr %a, i40 %b) sanitize_hwaddress {
; RECOVER-NEXT: store i40 [[B]], ptr [[A]], align 4
; RECOVER-NEXT: ret void
;
+; ABORT-INLINE-LABEL: define void @test_store40
+; ABORT-INLINE-SAME: (ptr [[A:%.*]], i40 [[B:%.*]]) #[[ATTR0]] {
+; ABORT-INLINE-NEXT: entry:
+; ABORT-INLINE-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
+; ABORT-INLINE-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
+; ABORT-INLINE-NEXT: call void @__hwasan_storeN(i64 [[TMP0]], i64 5)
+; ABORT-INLINE-NEXT: store i40 [[B]], ptr [[A]], align 4
+; ABORT-INLINE-NEXT: ret void
+;
+; RECOVER-INLINE-LABEL: define void @test_store40
+; RECOVER-INLINE-SAME: (ptr [[A:%.*]], i40 [[B:%.*]]) #[[ATTR0]] {
+; RECOVER-INLINE-NEXT: entry:
+; RECOVER-INLINE-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
+; RECOVER-INLINE-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
+; RECOVER-INLINE-NEXT: call void @__hwasan_storeN_noabort(i64 [[TMP0]], i64 5)
+; RECOVER-INLINE-NEXT: store i40 [[B]], ptr [[A]], align 4
+; RECOVER-INLINE-NEXT: ret void
+;
@@ -136,6 +210,24 @@ define void @test_store_unaligned(ptr %a, i64 %b) sanitize_hwaddress {
; RECOVER-NEXT: store i64 [[B]], ptr [[A]], align 4
; RECOVER-NEXT: ret void
;
+; ABORT-INLINE-LABEL: define void @test_store_unaligned
+; ABORT-INLINE-SAME: (ptr [[A:%.*]], i64 [[B:%.*]]) #[[ATTR0]] {
+; ABORT-INLINE-NEXT: entry:
+; ABORT-INLINE-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
+; ABORT-INLINE-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
+; ABORT-INLINE-NEXT: call void @__hwasan_storeN(i64 [[TMP0]], i64 8)
+; ABORT-INLINE-NEXT: store i64 [[B]], ptr [[A]], align 4
+; ABORT-INLINE-NEXT: ret void
+;
+; RECOVER-INLINE-LABEL: define void @test_store_unaligned
+; RECOVER-INLINE-SAME: (ptr [[A:%.*]], i64 [[B:%.*]]) #[[ATTR0]] {
+; RECOVER-INLINE-NEXT: entry:
+; RECOVER-INLINE-NEXT: [[DOTHWASAN_SHADOW:%.*]] = call ptr asm "", "=r,0"(ptr null)
+; RECOVER-INLINE-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
+; RECOVER-INLINE-NEXT: call void @__hwasan_storeN_noabort(i64 [[TMP0]], i64 8)
+; RECOVER-INLINE-NEXT: store i64 [[B]], ptr [[A]], align 4
+; RECOVER-INLINE-NEXT: ret void
+;
More information about the llvm-commits
mailing list