diff options
author | Eric Christopher <echristo@gmail.com> | 2014-04-07 13:36:21 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2014-04-07 13:36:21 +0000 |
commit | beb2cd6b7c3646cd7af42797d57513b67255b43c (patch) | |
tree | 6bc323e569e5de897168baab2dc916aaa470df00 /llvm/lib/Analysis | |
parent | 886c6a645f451ddb56df609c2bb6fe7388045f3e (diff) | |
download | bcm5719-llvm-beb2cd6b7c3646cd7af42797d57513b67255b43c.tar.gz bcm5719-llvm-beb2cd6b7c3646cd7af42797d57513b67255b43c.zip |
Handle vlas during inline cost computation if they'll be turned
into a constant size alloca by inlining.
Ran a run over the testsuite, no results out of the noise, fixes
the testcase in the PR.
PR19115.
llvm-svn: 205710
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/IPA/InlineCost.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/IPA/InlineCost.cpp b/llvm/lib/Analysis/IPA/InlineCost.cpp index 8dafc1c1c61..a803f8c3bf9 100644 --- a/llvm/lib/Analysis/IPA/InlineCost.cpp +++ b/llvm/lib/Analysis/IPA/InlineCost.cpp @@ -287,8 +287,17 @@ bool CallAnalyzer::accumulateGEPOffset(GEPOperator &GEP, APInt &Offset) { } bool CallAnalyzer::visitAlloca(AllocaInst &I) { - // FIXME: Check whether inlining will turn a dynamic alloca into a static + // Check whether inlining will turn a dynamic alloca into a static // 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?"); + Type *Ty = I.getAllocatedType(); + AllocatedSize += Ty->getPrimitiveSizeInBits() * AllocSize->getZExtValue(); + return Base::visitAlloca(I); + } + } // Accumulate the allocated size. if (I.isStaticAlloca()) { |