[llvm] 210ecf7 - [Instrumentor] Use CreateAllocationSize to compute size of alloca (#226330)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 14:10:46 PDT 2026
Author: Eli Friedman
Date: 2026-09-25T14:10:38-07:00
New Revision: 210ecf77c9021941ee32c496df8b715615163df4
URL: https://github.com/llvm/llvm-project/commit/210ecf77c9021941ee32c496df8b715615163df4
DIFF: https://github.com/llvm/llvm-project/commit/210ecf77c9021941ee32c496df8b715615163df4.diff
LOG: [Instrumentor] Use CreateAllocationSize to compute size of alloca (#226330)
No significant functional change, but the IR might look slightly
different.
Added:
Modified:
llvm/lib/Transforms/IPO/Instrumentor.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/Instrumentor.cpp b/llvm/lib/Transforms/IPO/Instrumentor.cpp
index c12ff5e69c03d..afbfcdb196afb 100644
--- a/llvm/lib/Transforms/IPO/Instrumentor.cpp
+++ b/llvm/lib/Transforms/IPO/Instrumentor.cpp
@@ -1171,22 +1171,7 @@ void AllocaIO::init(InstrumentationConfig &IConf, InstrumentorIRBuilderTy &IIRB,
Value *AllocaIO::getSize(Value &V, Type &Ty, InstrumentationConfig &IO,
InstrumentorIRBuilderTy &IIRB) {
auto &AI = cast<AllocaInst>(V);
- const DataLayout &DL = AI.getDataLayout();
- Value *SizeValue = nullptr;
- TypeSize TypeSize = AI.getAllocationBaseSize(DL);
- if (TypeSize.isFixed()) {
- SizeValue = getCI(&Ty, TypeSize.getFixedValue());
- } else {
- auto *NullPtr = ConstantPointerNull::get(AI.getType());
- SizeValue = IIRB.IRB.CreatePtrToInt(
- IIRB.IRB.CreateGEP(AI.getAllocatedType(), NullPtr,
- {IIRB.IRB.getInt32(1)}),
- &Ty);
- }
- if (AI.isArrayAllocation())
- SizeValue = IIRB.IRB.CreateMul(
- SizeValue, IIRB.IRB.CreateZExtOrBitCast(AI.getArraySize(), &Ty));
- return SizeValue;
+ return IIRB.IRB.CreateAllocationSize(&Ty, &AI);
}
Value *AllocaIO::setSize(Value &V, Value &NewV, InstrumentationConfig &IO,
More information about the llvm-commits
mailing list