mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Big diff for a small change: delete inlined functions if all callees have
inlined the function. Implements: Inline/inline_dce.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8101 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
namespace {
|
||||
Statistic<> NumInlined("inline", "Number of functions inlined");
|
||||
Statistic<> NumDeleted("inline", "Number of functions deleted because all callers found");
|
||||
cl::opt<unsigned> // FIXME: 200 is VERY conservative
|
||||
InlineLimit("inline-threshold", cl::Hidden, cl::init(200),
|
||||
cl::desc("Control the amount of inlining to perform (default = 200)"));
|
||||
@@ -139,7 +140,7 @@ bool FunctionInlining::doInlining(Function *F) {
|
||||
bool ShouldInc = true;
|
||||
// Found a call instruction? FIXME: This should also handle INVOKEs
|
||||
if (CallInst *CI = dyn_cast<CallInst>(I)) {
|
||||
if (Function *Callee = CI->getCalledFunction())
|
||||
if (Function *Callee = CI->getCalledFunction()) {
|
||||
doInlining(Callee); // Inline in callees before callers!
|
||||
|
||||
// Decide whether we should inline this function...
|
||||
@@ -162,6 +163,16 @@ bool FunctionInlining::doInlining(Function *F) {
|
||||
// Move to instruction before the call...
|
||||
I = (SI == BB->end()) ? BB->begin() : SI;
|
||||
ShouldInc = false; // Don't increment iterator until next time
|
||||
|
||||
// If we inlined the last possible call site to the function,
|
||||
// delete the function body now.
|
||||
if (Callee->use_empty() &&
|
||||
(Callee->hasInternalLinkage()||Callee->hasLinkOnceLinkage())){
|
||||
F->getParent()->getFunctionList().erase(Callee);
|
||||
++NumDeleted;
|
||||
if (Callee == F) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user