summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 0a32ef8a83b..d3b2930d7ea 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -329,12 +329,12 @@ bool CallAnalyzer::accumulateGEPOffset(GEPOperator &GEP, APInt &Offset) {
bool CallAnalyzer::visitAlloca(AllocaInst &I) {
// Check whether inlining will turn a dynamic alloca into a static
- // alloca, and handle that case.
+ // alloca and handle that case.
if (I.isArrayAllocation()) {
- if (Constant *Size = SimplifiedValues.lookup(I.getArraySize())) {
- ConstantInt *AllocSize = dyn_cast<ConstantInt>(Size);
- assert(AllocSize && "Allocation size not a constant int?");
+ Constant *Size = SimplifiedValues.lookup(I.getArraySize());
+ if (auto *AllocSize = dyn_cast_or_null<ConstantInt>(Size)) {
Type *Ty = I.getAllocatedType();
+ // FIXME: This can't be right. AllocatedSize is in *bytes*.
AllocatedSize += Ty->getPrimitiveSizeInBits() * AllocSize->getZExtValue();
return Base::visitAlloca(I);
}
OpenPOWER on IntegriCloud