diff options
author | Chris Lattner <sabre@nondot.org> | 2009-09-01 06:31:31 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-09-01 06:31:31 +0000 |
commit | a541b0fde2ab6b8b037edf113d42da41a2c5aae9 (patch) | |
tree | b552423321ef32d4577f0380d0ccc2575ab903be /lib/Analysis/IPA/CallGraph.cpp | |
parent | e5b1454cdd8522831093128ddc7d7f81328d9f33 (diff) |
Change CallGraphNode to maintain it's Function as an AssertingVH
for sanity. This didn't turn up any bugs.
Change CallGraphNode to maintain its "callsite" information in the
call edges list as a WeakVH instead of as an instruction*. This fixes
a broad class of dangling pointer bugs, and makes CallGraph have a number
of useful invariants again. This fixes the class of problem indicated
by PR4029 and PR3601.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80663 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/IPA/CallGraph.cpp')
-rw-r--r-- | lib/Analysis/IPA/CallGraph.cpp | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index 5757bfd897..d70b7ab763 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -241,7 +241,7 @@ void CallGraphNode::dump() const { print(errs()); } void CallGraphNode::removeCallEdgeFor(CallSite CS) { for (CalledFunctionsVector::iterator I = CalledFunctions.begin(); ; ++I) { assert(I != CalledFunctions.end() && "Cannot find callsite to remove!"); - if (I->first == CS) { + if (I->first == CS.getInstruction()) { I->second->DropRef(); *I = CalledFunctions.back(); CalledFunctions.pop_back(); @@ -250,21 +250,6 @@ void CallGraphNode::removeCallEdgeFor(CallSite CS) { } } -// FIXME: REMOVE THIS WHEN HACK IS REMOVED FROM CGSCCPASSMGR. -void CallGraphNode::removeCallEdgeFor(Instruction *CS) { - for (CalledFunctionsVector::iterator I = CalledFunctions.begin(); ; ++I) { - assert(I != CalledFunctions.end() && "Cannot find callsite to remove!"); - if (I->first.getInstruction() == CS) { - I->second->DropRef(); - *I = CalledFunctions.back(); - CalledFunctions.pop_back(); - return; - } - } - -} - - // removeAnyCallEdgeTo - This method removes any call edges from this node to // the specified callee function. This takes more time to execute than @@ -285,7 +270,7 @@ void CallGraphNode::removeOneAbstractEdgeTo(CallGraphNode *Callee) { for (CalledFunctionsVector::iterator I = CalledFunctions.begin(); ; ++I) { assert(I != CalledFunctions.end() && "Cannot find callee to remove!"); CallRecord &CR = *I; - if (CR.second == Callee && CR.first.getInstruction() == 0) { + if (CR.second == Callee && CR.first == 0) { Callee->DropRef(); *I = CalledFunctions.back(); CalledFunctions.pop_back(); @@ -301,9 +286,9 @@ void CallGraphNode::replaceCallSite(CallSite Old, CallSite New, CallGraphNode *NewCallee) { for (CalledFunctionsVector::iterator I = CalledFunctions.begin(); ; ++I) { assert(I != CalledFunctions.end() && "Cannot find callsite to replace!"); - if (I->first != Old) continue; + if (I->first != Old.getInstruction()) continue; - I->first = New; + I->first = New.getInstruction(); // If the callee is changing, not just the callsite, then update it as // well. |