diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-05-09 21:51:53 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-05-09 21:51:53 +0000 |
commit | 0f153424a919b7fa89a47bf10fe983c4d0536c55 (patch) | |
tree | 8728e42f9fd2568597212f28fe7ee7943707b4a4 /llvm/lib/Analysis/InlineCost.cpp | |
parent | c5508046b834c63ee2b8ac1448197f46d3944455 (diff) | |
download | bcm5719-llvm-0f153424a919b7fa89a47bf10fe983c4d0536c55.tar.gz bcm5719-llvm-0f153424a919b7fa89a47bf10fe983c4d0536c55.zip |
[Inliner] don't assume that a Constant alloca size is a ConstantInt (PR27277)
Differential Revision: http://reviews.llvm.org/D20077
llvm-svn: 268980
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 8 |
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); } |