summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-01-13 18:16:48 +0000
committerChris Lattner <sabre@nondot.org>2006-01-13 18:16:48 +0000
commit21f20558d629f7ff8f64c20746d890d29328a544 (patch)
treea48365b66fa9c80a4aaea9a64383cd0113b319a9 /lib/Transforms/Utils/InlineFunction.cpp
parent8acb249725e3304aafe91d5357f69722957c51b1 (diff)
downloadllvm-21f20558d629f7ff8f64c20746d890d29328a544.tar.gz
llvm-21f20558d629f7ff8f64c20746d890d29328a544.tar.bz2
llvm-21f20558d629f7ff8f64c20746d890d29328a544.tar.xz
Fix a bug I noticed by inspection: if the first instruction in the inlined
function was not an alloca, we wouldn't check the entry block for any allocas, leading to increased stack space in some cases. In practice, allocas are almost always at the top of the block, so this was never noticed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25280 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index cf45633447..40d02ab4bc 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -10,9 +10,6 @@
// This file implements inlining of a function into a call site, resolving
// parameters and the return value as appropriate.
//
-// FIXME: This pass should transform alloca instructions in the called function
-// into alloca/dealloca pairs! Or perhaps it should refuse to inline them!
-//
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Utils/Cloning.h"
@@ -87,13 +84,14 @@ bool llvm::InlineFunction(CallSite CS) {
// calculate which instruction they should be inserted before. We insert the
// instructions at the end of the current alloca list.
//
- if (isa<AllocaInst>(FirstNewBlock->begin())) {
+ {
BasicBlock::iterator InsertPoint = Caller->begin()->begin();
for (BasicBlock::iterator I = FirstNewBlock->begin(),
E = FirstNewBlock->end(); I != E; )
if (AllocaInst *AI = dyn_cast<AllocaInst>(I++))
if (isa<Constant>(AI->getArraySize())) {
- // Scan for the block of allocas that we can move over.
+ // Scan for the block of allocas that we can move over, and move them
+ // all at once.
while (isa<AllocaInst>(I) &&
isa<Constant>(cast<AllocaInst>(I)->getArraySize()))
++I;