Skip to content

Commit 4ca4460

Browse files
committed
[hwasan] Add "-hwasan-with-frame-record" (#109620)
It should not be implied form mapping settings. No longer disable frame records for fixed offset.
1 parent 489acb2 commit 4ca4460

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ static cl::opt<OffsetKind> ClMappingOffsetDynamic(
187187
clEnumValN(OffsetKind::kIfunc, "ifunc", "Use ifunc global"),
188188
clEnumValN(OffsetKind::kTls, "tls", "Use TLS")));
189189

190+
static cl::opt<bool>
191+
ClFrameRecords("hwasan-with-frame-record",
192+
cl::desc("Use ring buffer for stack allocations"),
193+
cl::Hidden);
194+
190195
static cl::opt<int> ClHotPercentileCutoff("hwasan-percentile-cutoff-hot",
191196
cl::desc("Hot percentile cuttoff."));
192197

@@ -1934,12 +1939,12 @@ void HWAddressSanitizer::ShadowMapping::init(Triple &TargetTriple,
19341939
SetFixed(0);
19351940
} else if (ClMappingOffset.getNumOccurrences() > 0) {
19361941
SetFixed(ClMappingOffset);
1937-
WithFrameRecord = false;
19381942
} else if (ClEnableKhwasan || InstrumentWithCalls) {
19391943
SetFixed(0);
19401944
WithFrameRecord = false;
19411945
} else if (ClMappingOffsetDynamic.getNumOccurrences() > 0) {
19421946
Kind = ClMappingOffsetDynamic;
1943-
WithFrameRecord = isInTls();
19441947
}
1948+
1949+
WithFrameRecord = optOr(ClFrameRecords, WithFrameRecord);
19451950
}

llvm/test/Instrumentation/HWAddressSanitizer/RISCV/alloca.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
; Test alloca instrumentation. Command line includes check-globals so that
33
; changes to debug-info are detectable.
44
;
5-
; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset-dynamic=ifunc -S | FileCheck %s --check-prefixes=DYNAMIC-SHADOW
6-
; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=ZERO-BASED-SHADOW
5+
; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset-dynamic=ifunc -hwasan-with-frame-record=0 -S | FileCheck %s --check-prefixes=DYNAMIC-SHADOW
6+
; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset=0 -hwasan-with-frame-record=0 -S | FileCheck %s --check-prefixes=ZERO-BASED-SHADOW
77

88
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
99
target triple = "riscv64-unknown-linux"

llvm/test/Instrumentation/HWAddressSanitizer/alloca.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
; Test alloca instrumentation. Command line includes check-globals so that
33
; changes to debug-info are detectable.
44
;
5-
; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset-dynamic=ifunc -S | FileCheck %s --check-prefixes=DYNAMIC-SHADOW
6-
; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=ZERO-BASED-SHADOW
5+
; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset-dynamic=ifunc -hwasan-with-frame-record=0 -S | FileCheck %s --check-prefixes=DYNAMIC-SHADOW
6+
; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset=0 -hwasan-with-frame-record=0 -S | FileCheck %s --check-prefixes=ZERO-BASED-SHADOW
77

8-
; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset-dynamic=ifunc -S --try-experimental-debuginfo-iterators | FileCheck %s --check-prefixes=DYNAMIC-SHADOW
9-
; RUN: opt < %s -passes=hwasan -hwasan-mapping-offset=0 -S --try-experimental-debuginfo-iterators | FileCheck %s --check-prefixes=ZERO-BASED-SHADOW
8+
; 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
9+
; 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
1010

1111
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
1212
target triple = "aarch64--linux-android10000"

llvm/test/Instrumentation/HWAddressSanitizer/prologue.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
; RUN: FileCheck %s --check-prefixes=NOIFUNC-TLS-HISTORY
88
; RUN: opt -passes=hwasan -S -hwasan-mapping-offset-dynamic=tls -hwasan-record-stack-history=none < %s | \
99
; RUN: FileCheck %s --check-prefixes=NOIFUNC-TLS-NOHISTORY
10-
; RUN: opt -passes=hwasan -S -hwasan-mapping-offset-dynamic=global < %s | \
10+
; RUN: opt -passes=hwasan -S -hwasan-mapping-offset-dynamic=global -hwasan-with-frame-record=0 < %s | \
1111
; RUN: FileCheck %s --check-prefixes=NOIFUNC-NOTLS
12-
; RUN: opt -passes=hwasan -S -hwasan-mapping-offset-dynamic=ifunc < %s | \
12+
; RUN: opt -passes=hwasan -S -hwasan-mapping-offset-dynamic=ifunc -hwasan-with-frame-record=0 < %s | \
1313
; RUN: FileCheck %s --check-prefixes=IFUNC-NOTLS
1414
; RUN: opt -passes=hwasan -S -mtriple=aarch64-fuchsia < %s | \
1515
; RUN: FileCheck %s --check-prefixes=FUCHSIA

0 commit comments

Comments
 (0)