[llvm] 083f0fa - [NFC][hwasan] Remove code duplication in ShadowMapping::init (#109618)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 23 16:55:45 PDT 2024
Author: Vitaly Buka
Date: 2024-09-23T16:55:42-07:00
New Revision: 083f0fa454b618d722424a4a530b91de18a1b3c0
URL: https://github.com/llvm/llvm-project/commit/083f0fa454b618d722424a4a530b91de18a1b3c0
DIFF: https://github.com/llvm/llvm-project/commit/083f0fa454b618d722424a4a530b91de18a1b3c0.diff
LOG: [NFC][hwasan] Remove code duplication in ShadowMapping::init (#109618)
The goal to is to reorder this function to make
initialization in following order:
1. Defaults
2. Target specific overrides
3. Explicit copt<> overrides
Added:
Modified:
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 1f9408b1b1f36b..2224397d089155 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1924,12 +1924,16 @@ void HWAddressSanitizer::instrumentPersonalityFunctions() {
void HWAddressSanitizer::ShadowMapping::init(Triple &TargetTriple,
bool InstrumentWithCalls) {
+ // Start with defaults.
Scale = kDefaultShadowScale;
+ Kind = OffsetKind::kTls;
+ WithFrameRecord = true;
+
+ // Tune for the target.
if (TargetTriple.isOSFuchsia()) {
// Fuchsia is always PIE, which means that the beginning of the address
// space is always available.
SetFixed(0);
- WithFrameRecord = true;
} else if (ClMappingOffset.getNumOccurrences() > 0) {
SetFixed(ClMappingOffset);
WithFrameRecord = false;
@@ -1939,10 +1943,7 @@ void HWAddressSanitizer::ShadowMapping::init(Triple &TargetTriple,
} else if (ClWithIfunc) {
Kind = OffsetKind::kIfunc;
WithFrameRecord = false;
- } else if (ClWithTls) {
- Kind = OffsetKind::kTls;
- WithFrameRecord = true;
- } else {
+ } else if (!ClWithTls) {
Kind = OffsetKind::kGlobal;
WithFrameRecord = false;
}
More information about the llvm-commits
mailing list