[llvm] 8fc1764 - [NFC][HWASAN] Check TagMaskByte instead of TargetTriple

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 25 20:05:13 PDT 2023


Author: Vitaly Buka
Date: 2023-04-25T20:04:58-07:00
New Revision: 8fc1764ef3d18b65b52f82ca4a6bf56ac024e589

URL: https://github.com/llvm/llvm-project/commit/8fc1764ef3d18b65b52f82ca4a6bf56ac024e589
DIFF: https://github.com/llvm/llvm-project/commit/8fc1764ef3d18b65b52f82ca4a6bf56ac024e589.diff

LOG: [NFC][HWASAN] Check TagMaskByte instead of TargetTriple

We need to apply mask for x86_64 because the mask is not full byte. So
instead checking the arch we can check the mask.

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 64cbc5a8418d..adc444bcfcd6 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1044,13 +1044,9 @@ unsigned HWAddressSanitizer::retagMask(unsigned AllocaNo) {
 }
 
 Value *HWAddressSanitizer::applyTagMask(IRBuilder<> &IRB, Value *OldTag) {
-  if (TargetTriple.getArch() == Triple::x86_64) {
-    Constant *TagMask = ConstantInt::get(IntptrTy, TagMaskByte);
-    Value *NewTag = IRB.CreateAnd(OldTag, TagMask);
-    return NewTag;
-  }
-  // aarch64 uses 8-bit tags, so no mask is needed.
-  return OldTag;
+  if (TagMaskByte == 0xFF)
+    return OldTag; // No need to clear the tag byte.
+  return IRB.CreateAnd(OldTag, ConstantInt::get(IntptrTy, TagMaskByte));
 }
 
 Value *HWAddressSanitizer::getNextTagWithCall(IRBuilder<> &IRB) {


        


More information about the llvm-commits mailing list