[PATCH] D156267: Enable hwasan-use-after-scope by default
Florian Mayer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 25 15:14:27 PDT 2023
fmayer created this revision.
Herald added subscribers: Enna1, hiraditya.
Herald added a project: All.
fmayer requested review of this revision.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.
This has been in use for a long time without any issues.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156267
Files:
compiler-rt/test/hwasan/TestCases/stack-uas.c
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/test/Instrumentation/HWAddressSanitizer/X86/alloca.ll
Index: llvm/test/Instrumentation/HWAddressSanitizer/X86/alloca.ll
===================================================================
--- llvm/test/Instrumentation/HWAddressSanitizer/X86/alloca.ll
+++ llvm/test/Instrumentation/HWAddressSanitizer/X86/alloca.ll
@@ -109,6 +109,7 @@
; CHECK-NEXT: [[TMP8:%.*]] = shl i64 [[TMP5]], 57
; CHECK-NEXT: [[TMP9:%.*]] = or i64 [[TMP7]], [[TMP8]]
; CHECK-NEXT: [[BUF_SROA_0_HWASAN:%.*]] = inttoptr i64 [[TMP9]] to ptr
+; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 16, ptr nonnull [[BUF_SROA_0]])
; CHECK-NEXT: [[TMP10:%.*]] = trunc i64 [[TMP5]] to i8
; CHECK-NEXT: call void @__hwasan_tag_memory(ptr [[BUF_SROA_0]], i8 [[TMP10]], i64 16)
; CHECK-NEXT: [[TMP11:%.*]] = ptrtoint ptr [[BUF_SROA_0_HWASAN]] to i64
@@ -116,6 +117,7 @@
; CHECK-NEXT: store volatile i8 0, ptr [[BUF_SROA_0_HWASAN]], align 4
; CHECK-NEXT: [[TMP12:%.*]] = trunc i64 [[HWASAN_UAR_TAG]] to i8
; CHECK-NEXT: call void @__hwasan_tag_memory(ptr [[BUF_SROA_0]], i8 [[TMP12]], i64 16)
+; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 16, ptr nonnull [[BUF_SROA_0]])
; CHECK-NEXT: ret i32 0
;
; INLINE-LABEL: define i32 @test_simple
@@ -148,6 +150,7 @@
; INLINE-NEXT: [[TMP19:%.*]] = shl i64 [[TMP16]], 57
; INLINE-NEXT: [[TMP20:%.*]] = or i64 [[TMP18]], [[TMP19]]
; INLINE-NEXT: [[BUF_SROA_0_HWASAN:%.*]] = inttoptr i64 [[TMP20]] to ptr
+; INLINE-NEXT: call void @llvm.lifetime.start.p0(i64 16, ptr nonnull [[BUF_SROA_0]])
; INLINE-NEXT: [[TMP21:%.*]] = trunc i64 [[TMP16]] to i8
; INLINE-NEXT: [[TMP22:%.*]] = ptrtoint ptr [[BUF_SROA_0]] to i64
; INLINE-NEXT: [[TMP23:%.*]] = and i64 [[TMP22]], -9079256848778919937
@@ -194,6 +197,7 @@
; INLINE-NEXT: [[TMP54:%.*]] = lshr i64 [[TMP53]], 4
; INLINE-NEXT: [[TMP55:%.*]] = getelementptr i8, ptr [[TMP14]], i64 [[TMP54]]
; INLINE-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[TMP55]], i8 [[TMP51]], i64 1, i1 false)
+; INLINE-NEXT: call void @llvm.lifetime.end.p0(i64 16, ptr nonnull [[BUF_SROA_0]])
; INLINE-NEXT: ret i32 0
;
entry:
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -134,7 +134,7 @@
static cl::opt<bool>
ClUseAfterScope("hwasan-use-after-scope",
cl::desc("detect use after scope within function"),
- cl::Hidden, cl::init(false));
+ cl::Hidden, cl::init(true));
static cl::opt<bool> ClGenerateTagsWithCalls(
"hwasan-generate-tags-with-calls",
Index: compiler-rt/test/hwasan/TestCases/stack-uas.c
===================================================================
--- compiler-rt/test/hwasan/TestCases/stack-uas.c
+++ compiler-rt/test/hwasan/TestCases/stack-uas.c
@@ -1,10 +1,10 @@
// Tests use-after-scope detection and reporting.
// RUN: %clang_hwasan -mllvm -hwasan-use-after-scope -g %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clang_hwasan -mllvm -hwasan-use-after-scope -g %s -o %t && not %env_hwasan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOSYM
+// Use after scope is turned on by default.
+// RUN: %clang_hwasan -g %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clang_hwasan -mllvm -hwasan-use-after-scope=false -g %s -o %t && %run %t 2>&1
-// Use after scope is turned off by default.
-// RUN: %clang_hwasan -g %s -o %t && %run %t 2>&1
// RUN: %clang_hwasan -mllvm -hwasan-use-after-scope -g %s -o %t && not %run %t 2>&1 | FileCheck %s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156267.544118.patch
Type: text/x-patch
Size: 3656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230725/7b9eaa47/attachment.bin>
More information about the llvm-commits
mailing list