// 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;
// 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.
// 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;
}
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