summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/Inliner.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2009-03-19 18:03:56 +0000
committerDale Johannesen <dalej@apple.com>2009-03-19 18:03:56 +0000
commit2050968df96a25a202c00d8e788a57c16e732188 (patch)
tree1e06039b303499c20455f12bdd1c1ea399bfd1c3 /llvm/lib/Transforms/IPO/Inliner.cpp
parent403c4680655de7ef3213ed47a2bf83614e4d9085 (diff)
downloadbcm5719-llvm-2050968df96a25a202c00d8e788a57c16e732188.tar.gz
bcm5719-llvm-2050968df96a25a202c00d8e788a57c16e732188.zip
Clear the cached cost when removing a function in
the inliner; prevents nondeterministic behavior when the same address is reallocated. Don't build call graph nodes for debug intrinsic calls; they're useless, and there were typically a lot of them. llvm-svn: 67311
Diffstat (limited to 'llvm/lib/Transforms/IPO/Inliner.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/Inliner.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp
index ed177478e16..c38a6ae4149 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -16,6 +16,7 @@
#define DEBUG_TYPE "inline"
#include "llvm/Module.h"
#include "llvm/Instructions.h"
+#include "llvm/IntrinsicInst.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Target/TargetData.h"
@@ -50,7 +51,7 @@ void Inliner::getAnalysisUsage(AnalysisUsage &Info) const {
// InlineCallIfPossible - If it is possible to inline the specified call site,
// do so and update the CallGraph for this operation.
-static bool InlineCallIfPossible(CallSite CS, CallGraph &CG,
+bool Inliner::InlineCallIfPossible(CallSite CS, CallGraph &CG,
const std::set<Function*> &SCCFunctions,
const TargetData &TD) {
Function *Callee = CS.getCalledFunction();
@@ -76,6 +77,8 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG,
// Remove any call graph edges from the callee to its callees.
CalleeNode->removeAllCalledFunctions();
+ resetCachedCostInfo(CalleeNode->getFunction());
+
// Removing the node for callee from the call graph and delete it.
delete CG.removeFunctionFromModule(CalleeNode);
++NumDeleted;
@@ -123,6 +126,7 @@ bool Inliner::shouldInline(CallSite CS) {
bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
CallGraph &CG = getAnalysis<CallGraph>();
+ TargetData &TD = getAnalysis<TargetData>();
std::set<Function*> SCCFunctions;
DOUT << "Inliner visiting SCC:";
@@ -142,7 +146,8 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) {
CallSite CS = CallSite::get(I);
- if (CS.getInstruction() && (!CS.getCalledFunction() ||
+ if (CS.getInstruction() && !isa<DbgInfoIntrinsic>(I) &&
+ (!CS.getCalledFunction() ||
!CS.getCalledFunction()->isDeclaration()))
CallSites.push_back(CS);
}
@@ -186,11 +191,10 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
if (shouldInline(CS)) {
Function *Caller = CS.getCaller();
// Attempt to inline the function...
- if (InlineCallIfPossible(CS, CG, SCCFunctions,
- getAnalysis<TargetData>())) {
- // Remove any cached cost info for this caller, as inlining the callee
- // has increased the size of the caller (which may be the same as the
- // callee).
+ if (InlineCallIfPossible(CS, CG, SCCFunctions, TD)) {
+ // Remove any cached cost info for this caller, as inlining the
+ // callee has increased the size of the caller (which may be the
+ // same as the callee).
resetCachedCostInfo(Caller);
// Remove this call site from the list. If possible, use
@@ -263,6 +267,7 @@ bool Inliner::removeDeadFunctions(CallGraph &CG,
bool Changed = false;
for (std::set<CallGraphNode*>::iterator I = FunctionsToRemove.begin(),
E = FunctionsToRemove.end(); I != E; ++I) {
+ resetCachedCostInfo((*I)->getFunction());
delete CG.removeFunctionFromModule(*I);
++NumDeleted;
Changed = true;
OpenPOWER on IntegriCloud