Skip to content

Conversation

@fmayer
Copy link
Contributor

@fmayer fmayer commented Dec 13, 2024

No description provided.

Created using spr 1.3.4
@llvmbot
Copy link
Member

llvmbot commented Dec 13, 2024

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

Author: Florian Mayer (fmayer)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp (+10-15)
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 530061e3b6bb7d..6333b1b6ba86f4 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1793,8 +1793,15 @@ void HWAddressSanitizer::instrumentGlobal(GlobalVariable *GV, uint8_t Tag) {
 }
 
 void HWAddressSanitizer::instrumentGlobals() {
-  std::vector<GlobalVariable *> Globals;
-  for (GlobalVariable &GV : M.globals()) {
+  MD5 Hasher;
+  Hasher.update(M.getSourceFileName());
+  MD5::MD5Result Hash;
+  Hasher.final(Hash);
+  uint8_t Tag = Hash[0];
+
+  assert(TagMaskByte >= 16);
+
+  for (GlobalVariable &GV : make_early_inc_range(M.globals())) {
     if (GV.hasSanitizerMetadata() && GV.getSanitizerMetadata().NoHWAddress)
       continue;
 
@@ -1812,24 +1819,12 @@ void HWAddressSanitizer::instrumentGlobals() {
     if (GV.hasSection())
       continue;
 
-    Globals.push_back(&GV);
-  }
-
-  MD5 Hasher;
-  Hasher.update(M.getSourceFileName());
-  MD5::MD5Result Hash;
-  Hasher.final(Hash);
-  uint8_t Tag = Hash[0];
-
-  assert(TagMaskByte >= 16);
-
-  for (GlobalVariable *GV : Globals) {
     // Don't allow globals to be tagged with something that looks like a
     // short-granule tag, otherwise we lose inter-granule overflow detection, as
     // the fast path shadow-vs-address check succeeds.
     if (Tag < 16 || Tag > TagMaskByte)
       Tag = 16;
-    instrumentGlobal(GV, Tag++);
+    instrumentGlobal(&GV, Tag++);
   }
 }
 

@llvmbot
Copy link
Member

llvmbot commented Dec 13, 2024

@llvm/pr-subscribers-llvm-transforms

Author: Florian Mayer (fmayer)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp (+10-15)
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 530061e3b6bb7d..6333b1b6ba86f4 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1793,8 +1793,15 @@ void HWAddressSanitizer::instrumentGlobal(GlobalVariable *GV, uint8_t Tag) {
 }
 
 void HWAddressSanitizer::instrumentGlobals() {
-  std::vector<GlobalVariable *> Globals;
-  for (GlobalVariable &GV : M.globals()) {
+  MD5 Hasher;
+  Hasher.update(M.getSourceFileName());
+  MD5::MD5Result Hash;
+  Hasher.final(Hash);
+  uint8_t Tag = Hash[0];
+
+  assert(TagMaskByte >= 16);
+
+  for (GlobalVariable &GV : make_early_inc_range(M.globals())) {
     if (GV.hasSanitizerMetadata() && GV.getSanitizerMetadata().NoHWAddress)
       continue;
 
@@ -1812,24 +1819,12 @@ void HWAddressSanitizer::instrumentGlobals() {
     if (GV.hasSection())
       continue;
 
-    Globals.push_back(&GV);
-  }
-
-  MD5 Hasher;
-  Hasher.update(M.getSourceFileName());
-  MD5::MD5Result Hash;
-  Hasher.final(Hash);
-  uint8_t Tag = Hash[0];
-
-  assert(TagMaskByte >= 16);
-
-  for (GlobalVariable *GV : Globals) {
     // Don't allow globals to be tagged with something that looks like a
     // short-granule tag, otherwise we lose inter-granule overflow detection, as
     // the fast path shadow-vs-address check succeeds.
     if (Tag < 16 || Tag > TagMaskByte)
       Tag = 16;
-    instrumentGlobal(GV, Tag++);
+    instrumentGlobal(&GV, Tag++);
   }
 }
 

@fmayer fmayer requested a review from pcc December 13, 2024 16:34
@fmayer
Copy link
Contributor Author

fmayer commented Dec 17, 2024

Actually that doesn't seem to work (looking at CI). Let me change back the MTE globals one too..

@fmayer fmayer closed this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants