diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-31 04:09:04 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-31 04:09:04 +0000 |
commit | 2f2110affaea0005ebe411451efdf7e6ca467b87 (patch) | |
tree | 29f4c85c79b1512d74e34f7f4f74cd4aeafc71f9 /llvm | |
parent | edcbfe85290b9337837921d029e0c2a5ce9a3413 (diff) | |
download | bcm5719-llvm-2f2110affaea0005ebe411451efdf7e6ca467b87.tar.gz bcm5719-llvm-2f2110affaea0005ebe411451efdf7e6ca467b87.zip |
simplify some code by making the SCCNodes set contain Function*'s
instead of CallGraphNode*'s. This also papers over a callgraph
problem where a pass (in this case, MemCpyOpt) introduces a new
function into the module (llvm.memset.i64) but doesn't add it to
the call graph (nor should it, since it is a function pass).
While it might be a good idea for MemCpyOpt to not synthesize
functions in a runOnFunction(), there is no need for FunctionAttrs
to be boneheaded, so fix it there. This fixes an assertion building
176.gcc.
llvm-svn: 80535
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionAttrs.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp index 7b72a5ff969..26b4152291e 100644 --- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp @@ -54,7 +54,7 @@ namespace { // IsFunctionMallocLike - Does this function allocate new memory? bool IsFunctionMallocLike(Function *F, - SmallPtrSet<CallGraphNode*, 8> &) const; + SmallPtrSet<Function*, 8> &) const; // AddNoAliasAttrs - Deduce noalias attributes for the SCC. bool AddNoAliasAttrs(const std::vector<CallGraphNode *> &SCC); @@ -93,13 +93,12 @@ bool FunctionAttrs::PointsToLocalMemory(Value *V) { /// AddReadAttrs - Deduce readonly/readnone attributes for the SCC. bool FunctionAttrs::AddReadAttrs(const std::vector<CallGraphNode *> &SCC) { - SmallPtrSet<CallGraphNode*, 8> SCCNodes; - CallGraph &CG = getAnalysis<CallGraph>(); + SmallPtrSet<Function*, 8> SCCNodes; // Fill SCCNodes with the elements of the SCC. Used for quickly // looking up whether a given CallGraphNode is in this SCC. for (unsigned i = 0, e = SCC.size(); i != e; ++i) - SCCNodes.insert(SCC[i]); + SCCNodes.insert(SCC[i]->getFunction()); // Check if any of the functions in the SCC read or write memory. If they // write memory then they can't be marked readnone or readonly. @@ -133,9 +132,9 @@ bool FunctionAttrs::AddReadAttrs(const std::vector<CallGraphNode *> &SCC) { // Some instructions can be ignored even if they read or write memory. // Detect these now, skipping to the next instruction if one is found. CallSite CS = CallSite::get(I); - if (CS.getInstruction()) { + if (CS.getInstruction() && CS.getCalledFunction()) { // Ignore calls to functions in the same SCC. - if (SCCNodes.count(CG[CS.getCalledFunction()])) + if (SCCNodes.count(CS.getCalledFunction())) continue; } else if (LoadInst *LI = dyn_cast<LoadInst>(I)) { // Ignore loads from local memory. @@ -226,9 +225,7 @@ bool FunctionAttrs::AddNoCaptureAttrs(const std::vector<CallGraphNode *> &SCC) { /// IsFunctionMallocLike - A function is malloc-like if it returns either null /// or a pointer that doesn't alias any other pointer visible to the caller. bool FunctionAttrs::IsFunctionMallocLike(Function *F, - SmallPtrSet<CallGraphNode*, 8> &SCCNodes) const { - CallGraph &CG = getAnalysis<CallGraph>(); - + SmallPtrSet<Function*, 8> &SCCNodes) const { UniqueVector<Value *> FlowsToReturn; for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) if (ReturnInst *Ret = dyn_cast<ReturnInst>(I->getTerminator())) @@ -275,7 +272,7 @@ bool FunctionAttrs::IsFunctionMallocLike(Function *F, if (CS.paramHasAttr(0, Attribute::NoAlias)) break; if (CS.getCalledFunction() && - SCCNodes.count(CG[CS.getCalledFunction()])) + SCCNodes.count(CS.getCalledFunction())) break; } // fall-through default: @@ -291,12 +288,12 @@ bool FunctionAttrs::IsFunctionMallocLike(Function *F, /// AddNoAliasAttrs - Deduce noalias attributes for the SCC. bool FunctionAttrs::AddNoAliasAttrs(const std::vector<CallGraphNode *> &SCC) { - SmallPtrSet<CallGraphNode*, 8> SCCNodes; + SmallPtrSet<Function*, 8> SCCNodes; // Fill SCCNodes with the elements of the SCC. Used for quickly // looking up whether a given CallGraphNode is in this SCC. for (unsigned i = 0, e = SCC.size(); i != e; ++i) - SCCNodes.insert(SCC[i]); + SCCNodes.insert(SCC[i]->getFunction()); // Check each function in turn, determining which functions return noalias // pointers. |