summaryrefslogtreecommitdiff
path: root/lib/Analysis/IPA
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2014-04-07 13:36:21 +0000
committerEric Christopher <echristo@gmail.com>2014-04-07 13:36:21 +0000
commit9a764dfa92ba7a8a64472410817459b00a8b003a (patch)
treebc85269d4a82b5b1f98ec4ce1fc5d17164556c86 /lib/Analysis/IPA
parent531bece9f586ef68017815f721cb99164e66d8dd (diff)
downloadllvm-9a764dfa92ba7a8a64472410817459b00a8b003a.tar.gz
llvm-9a764dfa92ba7a8a64472410817459b00a8b003a.tar.bz2
llvm-9a764dfa92ba7a8a64472410817459b00a8b003a.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205710 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/IPA')
-rw-r--r--lib/Analysis/IPA/InlineCost.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Analysis/IPA/InlineCost.cpp b/lib/Analysis/IPA/InlineCost.cpp
index 8dafc1c1c6..a803f8c3bf 100644
--- a/lib/Analysis/IPA/InlineCost.cpp
+++ b/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()) {