[PATCH] D118958: [hwasan] [nfc] simplify getAllocaSizeInBytes
Florian Mayer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 3 17:43:52 PST 2022
fmayer created this revision.
Herald added a subscriber: hiraditya.
fmayer requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
AllocaInst::getAllocationSize implements essentially the same logic as
our custom function.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D118958
Files:
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1057,15 +1057,8 @@
}
static uint64_t getAllocaSizeInBytes(const AllocaInst &AI) {
- 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();
- uint64_t SizeInBytes = AI.getModule()->getDataLayout().getTypeAllocSize(Ty);
- return SizeInBytes * ArraySize;
+ auto DL = AI.getModule()->getDataLayout();
+ return AI.getAllocationSizeInBits(DL).getValue() / 8;
}
void HWAddressSanitizer::tagAlloca(IRBuilder<> &IRB, AllocaInst *AI, Value *Tag,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118958.405841.patch
Type: text/x-patch
Size: 911 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220204/1a2e9397/attachment.bin>
More information about the llvm-commits
mailing list