35 for (
auto it = svfg.
begin(); it != svfg.
end(); ++it)
37 const VFGNode* vfg = it->second;
38 const ICFGNode* location = vfg->getICFGNode();
41 if (location && location->getFun())
47 for (const VFGEdge* edge : vfg->getInEdges())
49 if (const auto* call = SVFUtil::dyn_cast<CallIndSVFGEdge>(edge))
51 const ICFGNode* caller = call->getSrcNode()->getICFGNode();
54 for (NodeID obj : call->getPointsTo())
56 if (!svfir.isNullOrBlkObj(obj))
58 const NodeID base = svfir.getBaseObject(obj)->getId();
59 eventsByBase[base].insert(caller);
60 eventsByBase[base].insert(location);
61 addEdge(base, caller, location, nullptr);
70 const ValVar* pointer = nullptr;
71 if (const auto* memory = SVFUtil::dyn_cast<MRSVFGNode>(vfg))
73 for (NodeID obj : memory->getPointsTo())
75 if (!svfir.isNullOrBlkObj(obj))
77 const NodeID base = svfir.getBaseObject(obj)->getId();
78 eventsByBase[base].insert(location);
79 getOrCreateBaseObjNode(base, location);
83 else if (const auto* store = SVFUtil::dyn_cast<StoreVFGNode>(vfg))
84 pointer = store->getLHSVar();
85 else if (const auto* load = SVFUtil::dyn_cast<LoadVFGNode>(vfg))
86 pointer = load->getRHSVar();
93 for (NodeID obj : pta.getPts(pointer->getId()))
95 if (!svfir.isNullOrBlkObj(obj))
97 const NodeID base = svfir.getBaseObject(obj)->getId();
98 eventsByBase[base].insert(location);
99 getOrCreateBaseObjNode(base, location);
109 for (
auto it = icfg.begin(); it != icfg.end(); ++it)
111 if (const auto* ret = SVFUtil::dyn_cast<RetICFGNode>(it->second))
113 for (const VFGNode* target : ret->getVFGNodes())
115 for (const VFGEdge* edge : target->getInEdges())
117 if (const auto* output = SVFUtil::dyn_cast<RetIndSVFGEdge>(edge))
119 const ICFGNode* source = output->getSrcNode()->getICFGNode();
122 for (NodeID obj : output->getPointsTo())
124 if (!svfir.isNullOrBlkObj(obj))
126 const NodeID base = svfir.getBaseObject(obj)->getId();
127 returnedGroups[ret].insert(base);
128 if (source->getFun())
129 returnedGroupsByCallee[ret][source->getFun()].insert(base);
130 eventsByBase[base].insert(ret);
131 if (source->getFun())
132 eventsByBase[base].insert(source);
133 addEdge(base, source, ret, nullptr);
147 for (
const auto& [base, events] : eventsByBase)
150 for (
const ICFGNode* event : events)
151 sources.insert(icfg.getFunEntryICFGNode(event->getFun()));
154 if (svfir.getBaseObject(base)->isGlobalObj())
156 const ICFGNode* global = icfg.getGlobalICFGNode();
159 const ICFGNode* entry = edge->getDstNode();
161 addEdge(base, global, entry,
nullptr);
167 std::vector<const ICFGNode*> pending(sources.begin(), sources.end());
168 for (
size_t i = 0; i < pending.size(); ++i)
171 connectFrom(base, pending[i], events, newSources);
172 for (
const ICFGNode* event : newSources)
174 if (sources.insert(event).second)
175 pending.push_back(event);
266 std::vector<std::pair<const ICFGNode*, const IntraCFGEdge*>> first;
272 for (
const ICFGEdge* out : call->getOutEdges())
276 needsCallerToRetEdge =
true;
281 if (needsCallerToRetEdge)
282 first.emplace_back(call->getRetICFGNode(),
nullptr);
290 first.emplace_back(intra->getDstNode(),
291 intra->getCondition() ? intra :
nullptr);
295 for (
const auto& [start, branch] : first)
303 std::deque<const ICFGNode*> pending{start};
304 while (!pending.empty())
306 const ICFGNode* current = pending.front();
308 if (current && current->
getFun() == fun &&
309 visited.insert(current).second)
311 const bool objSite = events.count(current);
312 const bool controlBoundary =
isBranch(current) ||
315 if (objSite || controlBoundary)
317 addEdge(base, source, current, branch);
319 newSources.insert(current);
326 pending.push_back(intra->getDstNode());