enhance InlineFunction to be able to optionally return

a the list of static allocas that it inlined.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80203 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-08-27 04:20:52 +00:00
parent ec1bea0d94
commit 8f2718fbef
2 changed files with 25 additions and 9 deletions

View File

@ -29,11 +29,13 @@
#include "llvm/Support/CallSite.h"
using namespace llvm;
bool llvm::InlineFunction(CallInst *CI, CallGraph *CG, const TargetData *TD) {
return InlineFunction(CallSite(CI), CG, TD);
bool llvm::InlineFunction(CallInst *CI, CallGraph *CG, const TargetData *TD,
SmallVectorImpl<AllocaInst*> *StaticAllocas) {
return InlineFunction(CallSite(CI), CG, TD, StaticAllocas);
}
bool llvm::InlineFunction(InvokeInst *II, CallGraph *CG, const TargetData *TD) {
return InlineFunction(CallSite(II), CG, TD);
bool llvm::InlineFunction(InvokeInst *II, CallGraph *CG, const TargetData *TD,
SmallVectorImpl<AllocaInst*> *StaticAllocas) {
return InlineFunction(CallSite(II), CG, TD, StaticAllocas);
}
@ -265,7 +267,8 @@ static const DbgRegionEndInst *findFnRegionEndMarker(const Function *F) {
// exists in the instruction stream. Similiarly this will inline a recursive
// function by one level.
//
bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD,
SmallVectorImpl<AllocaInst*> *StaticAllocas) {
Instruction *TheCall = CS.getInstruction();
LLVMContext &Context = TheCall->getContext();
assert(TheCall->getParent() && TheCall->getParent()->getParent() &&
@ -435,11 +438,17 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
if (!isa<Constant>(AI->getArraySize()))
continue;
// Keep track of the static allocas that we inline into the caller if the
// StaticAllocas pointer is non-null.
if (StaticAllocas) StaticAllocas->push_back(AI);
// 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()))
isa<Constant>(cast<AllocaInst>(I)->getArraySize())) {
if (StaticAllocas) StaticAllocas->push_back(cast<AllocaInst>(I));
++I;
}
// Transfer all of the allocas over in a block. Using splice means
// that the instructions aren't removed from the symbol table, then