aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-01-13 19:35:43 +0000
committerChris Lattner <sabre@nondot.org>2006-01-13 19:35:43 +0000
commitccca3ca85f046bf7c99aa954ac121fdf59722499 (patch)
tree0b82f176404397de558c4bd37b1c691622e4ddf7
parentf0638c5f710996d355f91866179bd49fa991750f (diff)
Permit inlining functions that contain dynamic allocations now that
InlineFunction handles this case safely. This implements Transforms/Inline/dynamic_alloca_test.ll. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25288 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/IPO/InlineSimple.cpp31
1 files changed, 4 insertions, 27 deletions
diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp
index 0d579bc1ff..4a41bb6af5 100644
--- a/lib/Transforms/IPO/InlineSimple.cpp
+++ b/lib/Transforms/IPO/InlineSimple.cpp
@@ -33,16 +33,6 @@ namespace {
// FunctionInfo - For each function, calculate the size of it in blocks and
// instructions.
struct FunctionInfo {
- // HasAllocas - Keep track of whether or not a function contains an alloca
- // instruction that is not in the entry block of the function. Inlining
- // this call could cause us to blow out the stack, because the stack memory
- // would never be released.
- //
- // FIXME: LLVM needs a way of dealloca'ing memory, which would make this
- // irrelevant!
- //
- bool HasAllocas;
-
// NumInsts, NumBlocks - Keep track of how large each function is, which is
// used to estimate the code size cost of inlining it.
unsigned NumInsts, NumBlocks;
@@ -53,7 +43,7 @@ namespace {
// entry here.
std::vector<ArgInfo> ArgumentWeights;
- FunctionInfo() : HasAllocas(false), NumInsts(0), NumBlocks(0) {}
+ FunctionInfo() : NumInsts(0), NumBlocks(0) {}
/// analyzeFunction - Fill in the current structure with information gleaned
/// from the specified function.
@@ -148,17 +138,9 @@ void FunctionInfo::analyzeFunction(Function *F) {
// each instruction counts as 10.
for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
for (BasicBlock::const_iterator II = BB->begin(), E = BB->end();
- II != E; ++II) {
- if (!isa<DbgInfoIntrinsic>(II)) ++NumInsts;
-
- // If there is an alloca in the body of the function, we cannot currently
- // inline the function without the risk of exploding the stack.
- if (isa<AllocaInst>(II) && BB != F->begin()) {
- HasAllocas = true;
- this->NumBlocks = this->NumInsts = 1;
- return;
- }
- }
+ II != E; ++II)
+ if (!isa<DbgInfoIntrinsic>(II))
+ ++NumInsts;
++NumBlocks;
}
@@ -218,11 +200,6 @@ int SimpleInliner::getInlineCost(CallSite CS) {
if (CalleeFI.NumBlocks == 0)
CalleeFI.analyzeFunction(Callee);
- // Don't inline calls to functions with allocas that are not in the entry
- // block of the function.
- if (CalleeFI.HasAllocas)
- return 2000000000;
-
// Add to the inline quality for properties that make the call valuable to
// inline. This includes factors that indicate that the result of inlining
// the function will be optimizable. Currently this just looks at arguments