[llvm] c24d44f - [ASAN] Address a style issue noticed during review of D145175 [nfc]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 9 08:51:07 PST 2023


Author: Philip Reames
Date: 2023-03-09T08:50:59-08:00
New Revision: c24d44fd869a9f5d041dd15cda6c5ba8823539cd

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

LOG: [ASAN] Address a style issue noticed during review of D145175 [nfc]

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 0c10b68ff32a..2f9ef7b688a5 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1421,12 +1421,20 @@ static void doInstrumentAddress(AddressSanitizer *Pass, Instruction *I,
                                 uint32_t Exp) {
   // Instrument a 1-, 2-, 4-, 8-, or 16- byte access with one check
   // if the data is properly aligned.
-  if (!TypeStoreSize.isScalable() &&
-      (TypeStoreSize == 8 || TypeStoreSize == 16 || TypeStoreSize == 32 ||
-       TypeStoreSize == 64 || TypeStoreSize == 128) &&
-      (!Alignment || *Alignment >= Granularity || *Alignment >= TypeStoreSize / 8))
-    return Pass->instrumentAddress(I, InsertBefore, Addr, TypeStoreSize, IsWrite,
-                                   nullptr, UseCalls, Exp);
+  if (!TypeStoreSize.isScalable()) {
+    const auto FixedSize = TypeStoreSize.getFixedValue();
+    switch (FixedSize) {
+    case 8:
+    case 16:
+    case 32:
+    case 64:
+    case 128:
+      if (!Alignment || *Alignment >= Granularity ||
+          *Alignment >= FixedSize / 8)
+        return Pass->instrumentAddress(I, InsertBefore, Addr, FixedSize,
+                                       IsWrite, nullptr, UseCalls, Exp);
+    }
+  }
   Pass->instrumentUnusualSizeOrAlignment(I, InsertBefore, Addr, TypeStoreSize,
                                          IsWrite, nullptr, UseCalls, Exp);
 }


        


More information about the llvm-commits mailing list