[llvm] 77c90eb - [ASAN] Use AI.getAllocationSize() helper (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 15 08:52:01 PDT 2023


Author: Nikita Popov
Date: 2023-03-15T16:51:52+01:00
New Revision: 77c90ebeb7baaad71d306a8f611c78674f00e9f5

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

LOG: [ASAN] Use AI.getAllocationSize() helper (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 a6ae6c79523a..b3d4c4065556 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -668,16 +668,7 @@ struct AddressSanitizer {
   }
 
   TypeSize getAllocaSizeInBytes(const AllocaInst &AI) const {
-    uint64_t ArraySize = 1;
-    if (AI.isArrayAllocation()) {
-      const ConstantInt *CI = dyn_cast<ConstantInt>(AI.getArraySize());
-      assert(CI && "non-constant array size");
-      ArraySize = CI->getZExtValue();
-    }
-    Type *Ty = AI.getAllocatedType();
-    TypeSize SizeInBytes =
-        AI.getModule()->getDataLayout().getTypeAllocSize(Ty);
-    return SizeInBytes * ArraySize;
+    return *AI.getAllocationSize(AI.getModule()->getDataLayout());
   }
 
   /// Check if we want (and can) handle this alloca.


        


More information about the llvm-commits mailing list