[llvm] a6c2ab0 - [NFC][Alignment] Use proper type in instrumentLoadOrStore

Guillaume Chatelet via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 13 06:00:04 PDT 2022


Author: Guillaume Chatelet
Date: 2022-06-13T12:59:38Z
New Revision: a6c2ab0c3f66c20007bab6ca2c6a3a81e70f5d7a

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

LOG: [NFC][Alignment] Use proper type in instrumentLoadOrStore

Added: 
    

Modified: 
    llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
index 765baea4b80b..5cc5804dcbc5 100644
--- a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -636,8 +636,8 @@ bool ThreadSanitizer::instrumentLoadOrStore(const InstructionInfo &II,
     return true;
   }
 
-  const unsigned Alignment = IsWrite ? cast<StoreInst>(II.Inst)->getAlignment()
-                                     : cast<LoadInst>(II.Inst)->getAlignment();
+  const Align Alignment = IsWrite ? cast<StoreInst>(II.Inst)->getAlign()
+                                  : cast<LoadInst>(II.Inst)->getAlign();
   const bool IsCompoundRW =
       ClCompoundReadBeforeWrite && (II.Flags & InstructionInfo::kCompoundRW);
   const bool IsVolatile = ClDistinguishVolatile &&
@@ -647,7 +647,7 @@ bool ThreadSanitizer::instrumentLoadOrStore(const InstructionInfo &II,
 
   const uint32_t TypeSize = DL.getTypeStoreSizeInBits(OrigTy);
   FunctionCallee OnAccessFunc = nullptr;
-  if (Alignment == 0 || Alignment >= 8 || (Alignment % (TypeSize / 8)) == 0) {
+  if (Alignment >= Align(8) || (Alignment.value() % (TypeSize / 8)) == 0) {
     if (IsCompoundRW)
       OnAccessFunc = TsanCompoundRW[Idx];
     else if (IsVolatile)


        


More information about the llvm-commits mailing list