33 using namespace SVFUtil;
37 std::vector<const SVFBasicBlock *> &path,
38 std::vector<const SVFBasicBlock *> &tgtNodes,
44 tgtNodes.insert(tgtNodes.end(), path.begin() + 1, path.end());
49 for (
const auto &nxt: it->second)
51 dfsNodesBetweenPdomNodes(nxt, tgt, path, tgtNodes, ld);
66 std::vector<const SVFBasicBlock *> &tgtNodes)
68 if (succ == LCA)
return;
69 std::vector<const SVFBasicBlock *> path;
71 dfsNodesBetweenPdomNodes(LCA, succ, path, tgtNodes, ld);
79 if (_controlDG->getTotalNodeNum() > 0)
83 buildICFGNodeControlMap();
92 if (
const CallICFGNode* callNode = dyn_cast<CallICFGNode>(pred))
97 pred = callNode->getRetICFGNode();
100 if (
const IntraCFGEdge *intraEdge = SVFUtil::dyn_cast<IntraCFGEdge>(edge))
102 if(intraEdge->getCondition())
103 return intraEdge->getSuccessorCondValue();
109 assert(
false &&
"not intra edge?");
127 for (
const auto&
item: *svfirCallGraph)
133 extractBBS(svfFun, BBS);
135 for (
const auto &
item: BBS)
142 getLoopAndDomInfo()->findNearestCommonPDominator(pred, succ);
143 std::vector<const SVFBasicBlock *> tgtNodes;
146 tgtNodes.push_back(succ);
149 if (SVFLCA == pred) tgtNodes.push_back(SVFLCA);
151 extractNodesBetweenPdomNodes(succ, SVFLCA, tgtNodes);
154 s64_t pos = getBBSuccessorBranchID(pred, succ);
157 updateMap(pred, bb, pos);
174 for (
const auto &bb: *func)
176 for (
const auto &succ: bb->getSuccessors())
180 res[bb].push_back(succ);
190 for (
const auto &it: _svfcontrolMap)
192 for (
const auto &it2: it.second)
195 const ICFGNode *controlNode = it.first->getICFGNodeList().back();
197 SVFUtil::dyn_cast<CallICFGNode>(controlNode))
202 controlNode = callNode->getRetICFGNode();
204 if (!controlNode)
continue;
208 _nodeControlMap[controlNode][controllee].insert(it2.second.begin(), it2.second.end());
209 _nodeDependentOnMap[controllee][controlNode].insert(it2.second.begin(), it2.second.end());
210 for (
s32_t pos: it2.second)
213 dyn_cast<IntraICFGNode>(controlNode))
215 assert(intraNode->getSVFStmts().size() == 1 &&
216 "not a branch stmt?");
218 SVFUtil::cast<BranchStmt>(
219 intraNode->getSVFStmts().front())
221 _controlDG->addCDGEdgeFromSrcDst(controlNode, controllee,
231 _controlDG->addCDGEdgeFromSrcDst(
232 controlNode, controllee,
void extractNodesBetweenPdomNodes(const SVFBasicBlock *succ, const SVFBasicBlock *LCA, std::vector< const SVFBasicBlock * > &tgtNodes)
extract nodes between two nodes in pdom tree
void dfsNodesBetweenPdomNodes(const SVFBasicBlock *cur, const SVFBasicBlock *tgt, std::vector< const SVFBasicBlock * > &path, std::vector< const SVFBasicBlock * > &tgtNodes, SVFLoopAndDomInfo *ld)
void buildControlDependence(const SVFModule *svfgModule)
build control dependence for each function
void buildICFGNodeControlMap()
build map at icfg node level
static void extractBBS(const SVFFunction *func, Map< const SVFBasicBlock *, std::vector< const SVFBasicBlock * >> &res)
extract basic block edges to be processed
s64_t getBBSuccessorBranchID(const SVFBasicBlock *BB, const SVFBasicBlock *Succ)
NodeType * getGNode(NodeID id) const
Get a node.
ICFGEdge * getICFGEdge(const ICFGNode *src, const ICFGNode *dst, ICFGEdge::ICFGEdgeK kind)
Get a SVFG edge according to src and dst.
NodeID getNullPtr() const
const std::vector< const ICFGNode * > & getICFGNodeList() const
const ICFGNode * front() const
const ICFGNode * back() const
const SVFFunction * getFunction() const
bool postDominate(const SVFBasicBlock *bbKey, const SVFBasicBlock *bbValue) const
PTACallGraph * getCallGraph()
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
const Map< const SVFBasicBlock *, BBSet > & getPostDomTreeMap() const
const SVFFunction * getFunction(const std::string &name)
Get the corresponding Function based on its name.
bool isExtCall(const SVFFunction *fun)
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map