[llvm-branch-commits] [NFC][hwasan] Remove code duplication in ShadowMapping::init (PR #109618)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Sep 23 00:27:01 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/109618.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp (+6-5) 


``````````diff
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 2efb97c8759bc9..b82bb353793e7f 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1925,12 +1925,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;
@@ -1940,10 +1944,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;
   }

``````````

</details>


https://github.com/llvm/llvm-project/pull/109618


More information about the llvm-branch-commits mailing list