[llvm] 4ca4460 - [hwasan] Add "-hwasan-with-frame-record" (#109620)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 24 19:47:26 PDT 2024
Author: Vitaly Buka
Date: 2024-09-24T19:46:23-07:00
New Revision: 4ca4460bae12eefe90bf69704a33bdd5b1c9f142
URL: https://github.com/llvm/llvm-project/commit/4ca4460bae12eefe90bf69704a33bdd5b1c9f142
DIFF: https://github.com/llvm/llvm-project/commit/4ca4460bae12eefe90bf69704a33bdd5b1c9f142.diff
LOG: [hwasan] Add "-hwasan-with-frame-record" (#109620)
It should not be implied form mapping settings.
No longer disable frame records for fixed offset.
Added:
Modified:
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/test/Instrumentation/HWAddressSanitizer/RISCV/alloca.ll
llvm/test/Instrumentation/HWAddressSanitizer/alloca.ll
llvm/test/Instrumentation/HWAddressSanitizer/prologue.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 49d463a07553f2..7d3db5c2c8d5c3 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -187,6 +187,11 @@ static cl::opt<OffsetKind> ClMappingOffsetDynamic(
clEnumValN(OffsetKind::kIfunc, "ifunc", "Use ifunc global"),
clEnumValN(OffsetKind::kTls, "tls", "Use TLS")));
+static cl::opt<bool>
+ ClFrameRecords("hwasan-with-frame-record",
+ cl::desc("Use ring buffer for stack allocations"),
+ cl::Hidden);
+
static cl::opt<int> ClHotPercentileCutoff("hwasan-percentile-cutoff-hot",
cl::desc("Hot percentile cuttoff."));
@@ -1934,12 +1939,12 @@ void HWAddressSanitizer::ShadowMapping::init(Triple &TargetTriple,
SetFixed(0);
} else if (ClMappingOffset.getNumOccurrences() > 0) {
SetFixed(ClMappingOffset);
- WithFrameRecord = false;
} else if (ClEnableKhwasan || InstrumentWithCalls) {
SetFixed(0);
WithFrameRecord = false;
} else if (ClMappingOffsetDynamic.getNumOccurrences() > 0) {
Kind = ClMappingOffsetDynamic;
- WithFrameRecord = isInTls();
}
+
+ WithFrameRecord = optOr(ClFrameRecords, WithFrameRecord);
}
diff --git a/llvm/test/Instrumentation/HWAddressSanitizer/RISCV/alloca.ll b/llvm/test/Instrumentation/HWAddressSanitizer/RISCV/alloca.ll
index 24a89af97cffeb..edbcdbeb8516cd 100644
--- a/llvm/test/Instrumentation/HWAddressSanitizer/RISCV/alloca.ll
+++ b/llvm/test/Instrumentation/HWAddressSanitizer/RISCV/alloca.ll
@@ -2,8 +2,8 @@
; Test alloca instrumentation. Command line includes check-globals so that
; changes to debug-info are detectable.
;
-; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset-dynamic=ifunc -S | FileCheck %s --check-prefixes=DYNAMIC-SHADOW
-; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=ZERO-BASED-SHADOW
+; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset-dynamic=ifunc -hwasan-with-frame-record=0 -S | FileCheck %s --check-prefixes=DYNAMIC-SHADOW
+; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset=0 -hwasan-with-frame-record=0 -S | FileCheck %s --check-prefixes=ZERO-BASED-SHADOW
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "riscv64-unknown-linux"
diff --git a/llvm/test/Instrumentation/HWAddressSanitizer/alloca.ll b/llvm/test/Instrumentation/HWAddressSanitizer/alloca.ll
index 4d0cce72470b96..451ab9ee184a3a 100644
--- a/llvm/test/Instrumentation/HWAddressSanitizer/alloca.ll
+++ b/llvm/test/Instrumentation/HWAddressSanitizer/alloca.ll
@@ -2,11 +2,11 @@
; Test alloca instrumentation. Command line includes check-globals so that
; changes to debug-info are detectable.
;
-; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset-dynamic=ifunc -S | FileCheck %s --check-prefixes=DYNAMIC-SHADOW
-; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=ZERO-BASED-SHADOW
+; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset-dynamic=ifunc -hwasan-with-frame-record=0 -S | FileCheck %s --check-prefixes=DYNAMIC-SHADOW
+; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset=0 -hwasan-with-frame-record=0 -S | FileCheck %s --check-prefixes=ZERO-BASED-SHADOW
-; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset-dynamic=ifunc -S --try-experimental-debuginfo-iterators | FileCheck %s --check-prefixes=DYNAMIC-SHADOW
-; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset=0 -S --try-experimental-debuginfo-iterators | FileCheck %s --check-prefixes=ZERO-BASED-SHADOW
+; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset-dynamic=ifunc -hwasan-with-frame-record=0 -S --try-experimental-debuginfo-iterators | FileCheck %s --check-prefixes=DYNAMIC-SHADOW
+; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset=0 -hwasan-with-frame-record=0 -S --try-experimental-debuginfo-iterators | FileCheck %s --check-prefixes=ZERO-BASED-SHADOW
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64--linux-android10000"
diff --git a/llvm/test/Instrumentation/HWAddressSanitizer/prologue.ll b/llvm/test/Instrumentation/HWAddressSanitizer/prologue.ll
index 005a11b00c7a56..73fc077c956242 100644
--- a/llvm/test/Instrumentation/HWAddressSanitizer/prologue.ll
+++ b/llvm/test/Instrumentation/HWAddressSanitizer/prologue.ll
@@ -7,9 +7,9 @@
; RUN: FileCheck %s --check-prefixes=NOIFUNC-TLS-HISTORY
; RUN: opt -passes=hwasan -S -hwasan-mapping-offset-dynamic=tls -hwasan-record-stack-history=none < %s | \
; RUN: FileCheck %s --check-prefixes=NOIFUNC-TLS-NOHISTORY
-; RUN: opt -passes=hwasan -S -hwasan-mapping-offset-dynamic=global < %s | \
+; RUN: opt -passes=hwasan -S -hwasan-mapping-offset-dynamic=global -hwasan-with-frame-record=0 < %s | \
; RUN: FileCheck %s --check-prefixes=NOIFUNC-NOTLS
-; RUN: opt -passes=hwasan -S -hwasan-mapping-offset-dynamic=ifunc < %s | \
+; RUN: opt -passes=hwasan -S -hwasan-mapping-offset-dynamic=ifunc -hwasan-with-frame-record=0 < %s | \
; RUN: FileCheck %s --check-prefixes=IFUNC-NOTLS
; RUN: opt -passes=hwasan -S -mtriple=aarch64-fuchsia < %s | \
; RUN: FileCheck %s --check-prefixes=FUCHSIA
More information about the llvm-commits
mailing list