-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix incorrect implementation of getting CallGraphSCCRevTopoOrder #1640
base: master
Are you sure you want to change the base?
Changes from 2 commits
6c78ae1
e8e7e85
733d5be
9d4302f
d50f567
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,31 +69,23 @@ class WPAFSSolver : public WPASolver<GraphType> | |
/// SCC detection | ||
this->getSCCDetector()->find(); | ||
|
||
assert(nodeStack.empty() && "node stack is not empty, some nodes are not popped properly."); | ||
|
||
/// Both rep and sub nodes need to be processed later. | ||
/// Collect sub nodes from SCCDetector. | ||
NodeStack revTopoStack; | ||
NodeStack& topoStack = this->getSCCDetector()->topoNodeStack(); | ||
while (!topoStack.empty()) | ||
NodeStack revTopoStack = this->getSCCDetector()->revTopoNodeStack(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why making changes on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems correct. |
||
while (!revTopoStack.empty()) | ||
{ | ||
NodeID nodeId = topoStack.top(); | ||
topoStack.pop(); | ||
NodeID nodeId = revTopoStack.top(); | ||
revTopoStack.pop(); | ||
const NodeBS& subNodes = this->getSCCDetector()->subNodes(nodeId); | ||
for (NodeBS::iterator it = subNodes.begin(), eit = subNodes.end(); it != eit; ++it) | ||
{ | ||
revTopoStack.push(*it); | ||
/// restore the topological order. | ||
nodeStack.push(*it); | ||
} | ||
} | ||
|
||
assert(nodeStack.empty() && "node stack is not empty, some nodes are not popped properly."); | ||
|
||
/// restore the topological order. | ||
while (!revTopoStack.empty()) | ||
{ | ||
NodeID nodeId = revTopoStack.top(); | ||
revTopoStack.pop(); | ||
nodeStack.push(nodeId); | ||
} | ||
|
||
return nodeStack; | ||
} | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,6 +250,7 @@ void MRGenerator::collectModRefForCall() | |
{ | ||
PTACallGraphNode* subCallGraphNode = callGraph->getCallGraphNode(*it); | ||
/// Get mod-ref of all callsites calling callGraphNode | ||
std::cout << subCallGraphNode->getFunction()->getName() << std::endl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this debugging line. |
||
modRefAnalysis(subCallGraphNode,worklist); | ||
} | ||
} | ||
|
@@ -461,12 +462,11 @@ bool MRGenerator::addModSideEffectOfCallSite(const CallICFGNode* cs, const NodeB | |
*/ | ||
void MRGenerator::getCallGraphSCCRevTopoOrder(WorkList& worklist) | ||
{ | ||
|
||
NodeStack& topoOrder = callGraphSCC->topoNodeStack(); | ||
while(!topoOrder.empty()) | ||
NodeStack revTopoNodeStack = callGraphSCC->revTopoNodeStack(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @canliture I think we could just revise this method by using one line: could you validate the correctness again? |
||
while(!revTopoNodeStack.empty()) | ||
{ | ||
NodeID callgraphNodeID = topoOrder.top(); | ||
topoOrder.pop(); | ||
NodeID callgraphNodeID = revTopoNodeStack.top(); | ||
revTopoNodeStack.pop(); | ||
worklist.push(callgraphNodeID); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -709,24 +709,20 @@ inline void Andersen::collapseFields() | |
*/ | ||
void Andersen::mergeSccCycle() | ||
{ | ||
NodeStack revTopoOrder; | ||
NodeStack & topoOrder = getSCCDetector()->topoNodeStack(); | ||
while (!topoOrder.empty()) | ||
NodeStack revTopoOrder = getSCCDetector()->revTopoNodeStack(); | ||
/// referenced topoOrder is used for restoring the topological order for later solving. | ||
NodeStack &topoOrder = getSCCDetector()->topoNodeStack(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this line: |
||
while (!revTopoOrder.empty()) | ||
{ | ||
NodeID repNodeId = topoOrder.top(); | ||
topoOrder.pop(); | ||
revTopoOrder.push(repNodeId); | ||
NodeID repNodeId = revTopoOrder.top(); | ||
revTopoOrder.pop(); | ||
|
||
const NodeBS& subNodes = getSCCDetector()->subNodes(repNodeId); | ||
// merge sub nodes to rep node | ||
mergeSccNodes(repNodeId, subNodes); | ||
} | ||
|
||
// restore the topological order for later solving. | ||
while (!revTopoOrder.empty()) | ||
{ | ||
NodeID nodeId = revTopoOrder.top(); | ||
revTopoOrder.pop(); | ||
topoOrder.push(nodeId); | ||
/// restore the topological order for later solving. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no restore is needed as you never popped any element in |
||
topoOrder.push(repNodeId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this line |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callgraphNodeID => nodeID