mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-15 09:33:39 +00:00
make CallGraphNode dtor abort if a node is deleted when there are still
references to it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101847 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4471136e4d
commit
8a39ed75ec
@ -187,6 +187,9 @@ public:
|
|||||||
|
|
||||||
// CallGraphNode ctor - Create a node for the specified function.
|
// CallGraphNode ctor - Create a node for the specified function.
|
||||||
inline CallGraphNode(Function *f) : F(f), NumReferences(0) {}
|
inline CallGraphNode(Function *f) : F(f), NumReferences(0) {}
|
||||||
|
~CallGraphNode() {
|
||||||
|
assert(NumReferences == 0 && "Node deleted while references remain");
|
||||||
|
}
|
||||||
|
|
||||||
//===---------------------------------------------------------------------
|
//===---------------------------------------------------------------------
|
||||||
// Accessor methods.
|
// Accessor methods.
|
||||||
@ -277,6 +280,11 @@ public:
|
|||||||
/// time, so it should be used sparingly.
|
/// time, so it should be used sparingly.
|
||||||
void replaceCallEdge(CallSite CS, CallSite NewCS, CallGraphNode *NewNode);
|
void replaceCallEdge(CallSite CS, CallSite NewCS, CallGraphNode *NewNode);
|
||||||
|
|
||||||
|
/// allReferencesDropped - This is a special function that should only be
|
||||||
|
/// used by the CallGraph class.
|
||||||
|
void allReferencesDropped() {
|
||||||
|
NumReferences = 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -158,6 +158,7 @@ private:
|
|||||||
// destroy - Release memory for the call graph
|
// destroy - Release memory for the call graph
|
||||||
virtual void destroy() {
|
virtual void destroy() {
|
||||||
/// CallsExternalNode is not in the function map, delete it explicitly.
|
/// CallsExternalNode is not in the function map, delete it explicitly.
|
||||||
|
CallsExternalNode->allReferencesDropped();
|
||||||
delete CallsExternalNode;
|
delete CallsExternalNode;
|
||||||
CallsExternalNode = 0;
|
CallsExternalNode = 0;
|
||||||
CallGraph::destroy();
|
CallGraph::destroy();
|
||||||
@ -181,6 +182,14 @@ void CallGraph::initialize(Module &M) {
|
|||||||
void CallGraph::destroy() {
|
void CallGraph::destroy() {
|
||||||
if (FunctionMap.empty()) return;
|
if (FunctionMap.empty()) return;
|
||||||
|
|
||||||
|
// Reset all node's use counts to zero before deleting them to prevent an
|
||||||
|
// assertion from firing.
|
||||||
|
#ifndef NDEBUG
|
||||||
|
for (FunctionMapTy::iterator I = FunctionMap.begin(), E = FunctionMap.end();
|
||||||
|
I != E; ++I)
|
||||||
|
I->second->allReferencesDropped();
|
||||||
|
#endif
|
||||||
|
|
||||||
for (FunctionMapTy::iterator I = FunctionMap.begin(), E = FunctionMap.end();
|
for (FunctionMapTy::iterator I = FunctionMap.begin(), E = FunctionMap.end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
delete I->second;
|
delete I->second;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user