7 #include <boost/foreach.hpp>
11 using namespace boost;
17 template<
class CfgNodeT,
class CfgEdgeT>
18 multimap< CfgNodeT, pair<CfgNodeT, CfgEdgeT> >
22 multimap< CfgNodeT, pair<CfgNodeT, CfgEdgeT> > controlDepdendences;
25 set<CfgNodeT> visited;
26 set<CfgNodeT> worklist;
28 CfgNodeT sourceNode =
function->cfgForBeginning();
29 worklist.insert(sourceNode);
31 while (!worklist.empty())
34 sourceNode = *worklist.begin();
35 worklist.erase(worklist.begin());
36 visited.insert(sourceNode);
40 BOOST_FOREACH(
const CfgEdgeT& edge, sourceNode.outEdges())
42 CfgNodeT targetNode = edge.target();
45 if (visited.count(targetNode) == 0)
47 worklist.insert(targetNode);
56 typename map<CfgNodeT, CfgNodeT>::const_iterator parentIter = iPostDominatorMap.find(sourceNode);
57 ROSE_ASSERT(parentIter != iPostDominatorMap.end());
58 parent = parentIter->second;
61 CfgNodeT currNode = targetNode;
66 if (currNode == parent)
72 controlDepdendences.insert(make_pair(currNode, make_pair(sourceNode, edge)));
76 printf(
"%s is control-dependent on %s - %s \n", currNode.toStringForDebugging().c_str(),
77 sourceNode.toStringForDebugging().c_str(), edge.condition() ==
VirtualCFG::eckTrue ?
"true" :
"false");
81 parentIter = iPostDominatorMap.find(currNode);
82 ROSE_ASSERT(parentIter != iPostDominatorMap.end());
83 currNode = parentIter->second;
88 return controlDepdendences;