Static Value-Flow Analysis
Loading...
Searching...
No Matches
MemRegion.cpp
Go to the documentation of this file.
1//===- MemRegion.cpp -- Memory region-----------------------------------------//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-2017> <Yulei Sui>
6//
7
8// This program is free software: you can redistribute it and/or modify
9// it under the terms of the GNU Affero General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU Affero General Public License for more details.
17
18// You should have received a copy of the GNU Affero General Public License
19// along with this program. If not, see <http://www.gnu.org/licenses/>.
20//
21//===----------------------------------------------------------------------===//
22
23/*
24 * MemRegion.cpp
25 *
26 * Created on: Dec 14, 2013
27 * Author: Yulei Sui
28 */
29
30#include "Util/Options.h"
32#include "MSSA/MemRegion.h"
33#include "MSSA/MSSAMuChi.h"
34#include "Graphs/CallGraph.h"
35
36using namespace SVF;
37using namespace SVFUtil;
38
41
43 pta(p), ptrOnlyMSSA(ptrOnly)
44{
47}
48
53{
54
55 for (MRSet::iterator it = memRegSet.begin(), eit = memRegSet.end();
56 it != eit; ++it)
57 {
58 delete *it;
59 }
60
61 delete callGraphSCC;
62 callGraphSCC = nullptr;
63 callGraph = nullptr;
64 pta = nullptr;
65}
66
70void MRGenerator::createMR(const FunObjVar* fun, const NodeBS& cpts)
71{
72 const NodeBS& repCPts = getRepPointsTo(cpts);
74 MRSet::const_iterator mit = memRegSet.find(&mr);
75 if(mit!=memRegSet.end())
76 {
77 const MemRegion* mr = *mit;
78 MRSet& mrs = funToMRsMap[fun];
79 if(mrs.find(mr)==mrs.end())
80 mrs.insert(mr);
81 }
82 else
83 {
85 memRegSet.insert(m);
86 funToMRsMap[fun].insert(m);
87 }
88}
89
93const MemRegion* MRGenerator::getMR(const NodeBS& cpts) const
94{
95 MemRegion mr(getRepPointsTo(cpts));
96 MRSet::iterator mit = memRegSet.find(&mr);
97 assert(mit!=memRegSet.end() && "memory region not found!!");
98 return *mit;
99}
100
101
106{
107 SVFIR* pag = pta->getPAG();
108 for (SVFIR::iterator nIter = pag->begin(); nIter != pag->end(); ++nIter)
109 {
110 if(ObjVar* obj = SVFUtil::dyn_cast<ObjVar>(nIter->second))
111 {
112 if (pag->getBaseObject(obj->getId())->isGlobalObj())
113 {
114 allGlobals.set(nIter->first);
116 }
117 }
118 }
119}
120
126{
127
128 DBOUT(DGENERAL, outs() << pasMsg("Generate Memory Regions \n"));
129
131
132 callGraphSCC->find();
133
134 DBOUT(DGENERAL, outs() << pasMsg("\tCollect ModRef For Load/Store \n"));
135
138
139 DBOUT(DGENERAL, outs() << pasMsg("\tCollect ModRef For const CallICFGNode*\n"));
140
143
144 DBOUT(DGENERAL, outs() << pasMsg("\tPartition Memory Regions \n"));
146 partitionMRs();
149}
150
152{
153 SVFIR* pag = pta->getPAG();
154 if (ptrOnlyMSSA)
155 return pag->hasPTASVFStmtList(node);
156 else
157 return pag->hasSVFStmtList(node);
158}
159
160
162{
163 SVFIR* pag = pta->getPAG();
164 if (ptrOnlyMSSA)
165 return pag->getPTASVFStmtList(node);
166 else
167 return pag->getSVFStmtList(node);
168}
169
170
175{
176
178 for (const auto& item: *svfirCallGraph)
179 {
180 const FunObjVar& fun = *item.second->getFunction();
181
184 continue;
185
186 for (FunObjVar::const_bb_iterator iter = fun.begin(), eiter = fun.end();
187 iter != eiter; ++iter)
188 {
189 const SVFBasicBlock* bb = iter->second;
190 for (const auto& inst: bb->getICFGNodeList())
191 {
193 for (SVFStmtList::iterator bit = pagEdgeList.begin(), ebit =
194 pagEdgeList.end(); bit != ebit; ++bit)
195 {
196 const PAGEdge* inst = *bit;
197 pagEdgeToFunMap[inst] = &fun;
198 if (const StoreStmt *st = SVFUtil::dyn_cast<StoreStmt>(inst))
199 {
200 NodeBS cpts(pta->getPts(st->getLHSVarID()).toNodeBS());
201 // TODO: change this assertion check later when we have conditional points-to set
202 if (cpts.empty())
203 continue;
204 assert(!cpts.empty() && "null pointer!!");
205 addCPtsToStore(cpts, st, &fun);
206 }
207
208 else if (const LoadStmt *ld = SVFUtil::dyn_cast<LoadStmt>(inst))
209 {
210 NodeBS cpts(pta->getPts(ld->getRHSVarID()).toNodeBS());
211 // TODO: change this assertion check later when we have conditional points-to set
212 if (cpts.empty())
213 continue;
214 assert(!cpts.empty() && "null pointer!!");
215 addCPtsToLoad(cpts, ld, &fun);
216 }
217 }
218 }
219 }
220 }
221}
222
223
228{
229
230 DBOUT(DGENERAL, outs() << pasMsg("\t\tCollect Callsite PointsTo \n"));
231
233 for(SVFIR::CallSiteSet::const_iterator it = pta->getPAG()->getCallSiteSet().begin(),
234 eit = pta->getPAG()->getCallSiteSet().end(); it!=eit; ++it)
235 {
236 collectCallSitePts((*it));
237 }
238
239 DBOUT(DGENERAL, outs() << pasMsg("\t\tPerform Callsite Mod-Ref \n"));
240
241 WorkList worklist = callGraphSCC->revTopoNodeStack();
242
243 while(!worklist.empty())
244 {
245 NodeID callGraphNodeID = worklist.front();
246 worklist.pop();
248 const NodeBS& subNodes = callGraphSCC->subNodes(callGraphNodeID);
249 for(NodeBS::iterator it = subNodes.begin(), eit = subNodes.end(); it!=eit; ++it)
250 {
254 }
255 }
256
257 DBOUT(DGENERAL, outs() << pasMsg("\t\tAdd PointsTo to Callsites \n"));
258
259 for (const CallICFGNode* callBlockNode : pta->getPAG()->getCallSiteSet())
260 {
261 if(hasRefSideEffectOfCallSite(callBlockNode))
262 {
263 NodeBS refs = getRefSideEffectOfCallSite(callBlockNode);
264 addCPtsToCallSiteRefs(refs,callBlockNode);
265 }
266 if(hasModSideEffectOfCallSite(callBlockNode))
267 {
268 NodeBS mods = getModSideEffectOfCallSite(callBlockNode);
270 addCPtsToCallSiteMods(mods,callBlockNode);
271 addCPtsToCallSiteRefs(mods,callBlockNode);
272 }
273 }
274}
275
283{
284
285 if(cptsToRepCPtsMap.find(cpts)!=cptsToRepCPtsMap.end())
286 return;
287
289 NodeBS repCPts = cpts;
290 for(PtsToRepPtsSetMap::iterator it = cptsToRepCPtsMap.begin(),
291 eit = cptsToRepCPtsMap.end(); it!=eit; ++it)
292 {
293 NodeBS& existCPts = it->second;
294 if(cpts.contains(existCPts))
295 {
296 subSetList.insert(it->first);
297 }
298 else if(existCPts.contains(cpts))
299 {
301 }
302 }
303
304 for(PointsToList::iterator it = subSetList.begin(), eit = subSetList.end(); it!=eit; ++it)
305 {
306 cptsToRepCPtsMap[*it] = cpts;
307 }
308
310}
311
316{
317
322 for(FunToPointsTosMap::iterator it = getFunToPointsToList().begin(), eit = getFunToPointsToList().end();
323 it!=eit; ++it)
324 {
325 for(PointsToList::iterator cit = it->second.begin(), ecit = it->second.end(); cit!=ecit; ++cit)
326 {
328 }
329 }
331 for(FunToPointsTosMap::iterator it = getFunToPointsToList().begin(), eit = getFunToPointsToList().end();
332 it!=eit; ++it)
333 {
334 const FunObjVar* fun = it->first;
335 for(PointsToList::iterator cit = it->second.begin(), ecit = it->second.end(); cit!=ecit; ++cit)
336 {
337 createMR(fun,*cit);
338 }
339 }
340
341}
342
347{
348
350 for(StoresToPointsToMap::const_iterator it = storesToPointsToMap.begin(), eit = storesToPointsToMap.end(); it!=eit; ++it)
351 {
353 const FunObjVar* fun = getFunction(it->first);
354 const NodeBS& storeCPts = it->second;
356 for(MRSet::iterator ait = aliasMRs.begin(), eait = aliasMRs.end(); ait!=eait; ++ait)
357 {
358 storesToMRsMap[it->first].insert(*ait);
359 }
360 }
361
362 for(LoadsToPointsToMap::const_iterator it = loadsToPointsToMap.begin(), eit = loadsToPointsToMap.end(); it!=eit; ++it)
363 {
365 const FunObjVar* fun = getFunction(it->first);
366 const NodeBS& loadCPts = it->second;
368 for(MRSet::iterator ait = aliasMRs.begin(), eait = aliasMRs.end(); ait!=eait; ++ait)
369 {
370 loadsToMRsMap[it->first].insert(*ait);
371 }
372 }
373
375 for(CallSiteToPointsToMap::const_iterator it = callsiteToModPointsToMap.begin(),
376 eit = callsiteToModPointsToMap.end(); it!=eit; ++it)
377 {
378 const FunObjVar* fun = it->first->getCaller();
380 const NodeBS& callsiteModCPts = it->second;
382 for(MRSet::iterator ait = aliasMRs.begin(), eait = aliasMRs.end(); ait!=eait; ++ait)
383 {
384 callsiteToModMRsMap[it->first].insert(*ait);
385 }
386 }
387 for(CallSiteToPointsToMap::const_iterator it = callsiteToRefPointsToMap.begin(),
388 eit = callsiteToRefPointsToMap.end(); it!=eit; ++it)
389 {
390 const FunObjVar* fun = it->first->getCaller();
392 const NodeBS& callsiteRefCPts = it->second;
394 for(MRSet::iterator ait = aliasMRs.begin(), eait = aliasMRs.end(); ait!=eait; ++ait)
395 {
396 callsiteToRefMRsMap[it->first].insert(*ait);
397 }
398 }
399}
400
401
406{
407 for(NodeBS::iterator it = refs.begin(), eit = refs.end(); it!=eit; ++it)
408 {
409 if(isNonLocalObject(*it,fun))
410 funToRefsMap[fun].set(*it);
411 }
412}
413
418{
419 for(NodeBS::iterator it = mods.begin(), eit = mods.end(); it!=eit; ++it)
420 {
421 if(isNonLocalObject(*it,fun))
422 funToModsMap[fun].set(*it);
423 }
424}
425
430{
431 if(!refs.empty())
432 {
437 return csToRefsMap[cs] |= refset;
438 }
439 return false;
440}
441
446{
447 if(!mods.empty())
448 {
450 // Ordinary calls expose callee writes only through memory reachable from
451 // call arguments, return values, or globals.
455 return csToModsMap[cs] |= modset;
456 }
457 return false;
458}
459
461{
462 if(!mods.empty())
463 {
464 // Some specialised call-boundary effects are not represented by the
465 // call's argument/return points-to closure.
467 return csToModsMap[cs] |= mods;
468 }
469 return false;
470}
471
472
477{
480 SVFIR* pag = pta->getPAG();
481 CallICFGNode* callBlockNode = const_cast<CallICFGNode*>(cs);
483
484 WorkList worklist;
485 if (pag->hasCallSiteArgsMap(callBlockNode))
486 {
487 const SVFIR::ValVarList& args = pta->getPAG()->getCallSiteArgsList(callBlockNode);
488 for(SVFIR::ValVarList::const_iterator itA = args.begin(), ieA = args.end(); itA!=ieA; ++itA)
489 {
490 const PAGNode* node = *itA;
491 if(node->isPointer())
492 worklist.push(node->getId());
493 }
494 }
495
496 while(!worklist.empty())
497 {
498 NodeID nodeId = worklist.pop();
499 const NodeBS& tmp = pta->getPts(nodeId).toNodeBS();
500 for(NodeBS::iterator it = tmp.begin(), eit = tmp.end(); it!=eit; ++it)
501 argsPts |= CollectPtsChain(*it);
502 }
503
506
508 {
509 const PAGNode* node = pta->getPAG()->getCallSiteRet(retBlockNode);
510 if(node->isPointer())
511 {
512 const NodeBS& tmp = pta->getPts(node->getId()).toNodeBS();
513 for(NodeBS::iterator it = tmp.begin(), eit = tmp.end(); it!=eit; ++it)
514 retPts |= CollectPtsChain(*it);
515 }
516 }
517
518}
519
520
525{
527 NodeToPTSSMap::iterator it = cachedPtsChainMap.find(baseId);
528 if(it!=cachedPtsChainMap.end())
529 return it->second;
530 else
531 {
534
535 WorkList worklist;
536 for(NodeBS::iterator it = pts.begin(), eit = pts.end(); it!=eit; ++it)
537 worklist.push(*it);
538
539 while(!worklist.empty())
540 {
541 NodeID nodeId = worklist.pop();
542 const NodeBS& tmp = pta->getPts(nodeId).toNodeBS();
543 for(NodeBS::iterator it = tmp.begin(), eit = tmp.end(); it!=eit; ++it)
544 {
545 pts |= CollectPtsChain(*it);
546 }
547 }
548 return pts;
549 }
550
551}
552
559{
560 for(NodeBS::iterator it = calleeModRef.begin(), eit = calleeModRef.end(); it!=eit; ++it)
561 {
562 const BaseObjVar* pVar = pta->getPAG()->getBaseObject(*it);
563 (void)pVar;
564 //(void)obj; // Suppress warning of unused variable under release build
565 assert(pVar && "object not found!!");
566 if(allGlobals.test(*it))
567 globs.set(*it);
568 }
569}
570
576{
577 //ABTest
578 const BaseObjVar* obj = pta->getPAG()->getBaseObject(id);
579 assert(obj && "object not found!!");
581 const BaseObjVar* pVar = pta->getPAG()->getBaseObject(id);
582 assert(pVar && "object not found!");
583 if(obj->isGlobalObj() || SVFUtil::isa<HeapObjVar, DummyObjVar>(pVar))
584 return true;
587 else if(SVFUtil::isa<StackObjVar>(pVar))
588 {
589 if(const FunObjVar* svffun = pVar->getFunction())
590 {
591 if(svffun!=curFun)
592 return true;
593 else
594 return callGraphSCC->isInCycle(callGraph->getCallGraphNode(svffun)->getId());
595 }
596 }
597
598 return false;
599}
600
605{
607 if(isHeapAllocExtCall(cs))
608 {
610 for (SVFStmtList::const_iterator bit = pagEdgeList.begin(),
611 ebit = pagEdgeList.end(); bit != ebit; ++bit)
612 {
613 const PAGEdge* edge = *bit;
614 if (const AddrStmt* addr = SVFUtil::dyn_cast<AddrStmt>(edge))
615 mod.set(addr->getRHSVarID());
616 }
617 }
619 else
620 {
623 }
625 // add ref set
627 // add mod set
629
630 return refchanged || modchanged;
631}
632
638{
639
641 for(CallGraphNode::iterator it = callGraphNode->InEdgeBegin(), eit = callGraphNode->InEdgeEnd();
642 it!=eit; ++it)
643 {
644 CallGraphEdge* edge = *it;
645
647 for(CallGraphEdge::CallInstSet::iterator cit = edge->getDirectCalls().begin(),
648 ecit = edge->getDirectCalls().end(); cit!=ecit; ++cit)
649 {
650 NodeBS mod, ref;
651 const CallICFGNode* cs = (*cit);
652 bool modrefchanged = handleCallsiteModRef(mod, ref, cs, callGraphNode->getFunction());
653 if(modrefchanged)
654 worklist.push(edge->getSrcID());
655 }
657 for(CallGraphEdge::CallInstSet::iterator cit = edge->getIndirectCalls().begin(),
658 ecit = edge->getIndirectCalls().end(); cit!=ecit; ++cit)
659 {
660 NodeBS mod, ref;
661 const CallICFGNode* cs = (*cit);
662 bool modrefchanged = handleCallsiteModRef(mod, ref, cs, callGraphNode->getFunction());
663 if(modrefchanged)
664 worklist.push(edge->getSrcID());
665 }
666 }
667
668 propagateAdditionalModRef(callGraphNode, worklist);
669}
670
675{
676 if (isExtCall(cs) && !isHeapAllocExtCall(cs))
677 {
679 NodeBS mods;
680 for (SVFStmtList::const_iterator bit = pagEdgeList.begin(), ebit =
681 pagEdgeList.end(); bit != ebit; ++bit)
682 {
683 const PAGEdge* edge = *bit;
684 if (const StoreStmt* st = SVFUtil::dyn_cast<StoreStmt>(edge))
685 mods |= pta->getPts(st->getLHSVarID()).toNodeBS();
686 }
687 return mods;
688 }
689 else
690 {
692 }
693}
694
699{
700 if (isExtCall(cs) && !isHeapAllocExtCall(cs))
701 {
703 NodeBS refs;
704 for (SVFStmtList::const_iterator bit = pagEdgeList.begin(), ebit =
705 pagEdgeList.end(); bit != ebit; ++bit)
706 {
707 const PAGEdge* edge = *bit;
708 if (const LoadStmt* ld = SVFUtil::dyn_cast<LoadStmt>(edge))
709 refs |= pta->getPts(ld->getRHSVarID()).toNodeBS();
710 }
711 return refs;
712 }
713 else
714 {
716 }
717}
718
724{
725 bool ref = !getRefInfoForCall(cs).empty();
726 bool mod = !getModInfoForCall(cs).empty();
727
728 if (mod && ref)
729 return ModRefInfo::ModRef;
730 else if (ref)
731 return ModRefInfo::Ref;
732 else if (mod)
733 return ModRefInfo::Mod;
734 else
736}
737
743{
744 bool ref = false;
745 bool mod = false;
746
747 const NodeBS pts(pta->getPts(V->getId()).toNodeBS());
748 const NodeBS csRef = getRefInfoForCall(cs);
749 const NodeBS csMod = getModInfoForCall(cs);
754
755 if (csRefExpanded.intersects(ptsExpanded))
756 ref = true;
757 if (csModExpanded.intersects(ptsExpanded))
758 mod = true;
759
760 if (mod && ref)
761 return ModRefInfo::ModRef;
762 else if (ref)
763 return ModRefInfo::Ref;
764 else if (mod)
765 return ModRefInfo::Mod;
766 else
768}
769
774{
775 bool ref = false;
776 bool mod = false;
777
781
791
793 if (cs1RefExpanded.intersects(cs2ModExpanded))
794 ref = true;
796 if (cs1ModExpanded.intersects(cs2RefExpanded) || cs1ModExpanded.intersects(cs2ModExpanded))
797 mod = true;
799 if (cs1RefExpanded.intersects(cs2ModExpanded) && cs1ModExpanded.intersects(cs2ModExpanded))
800 ref = mod = true;
801
802 if (ref && mod)
803 return ModRefInfo::ModRef;
804 else if (ref)
805 return ModRefInfo::Ref;
806 else if (mod)
807 return ModRefInfo::Mod;
808 else
810}
811
812std::ostream& SVF::operator<<(std::ostream &o, const MRVer& mrver)
813{
814 o << "MRVERID: " << mrver.getID() <<" MemRegion: " << mrver.getMR()->dumpStr() << " MRVERSION: " << mrver.getSSAVersion() << " MSSADef: " << mrver.getDef()->getType() << ", "
815 << mrver.getDef()->getMR()->dumpStr() ;
816 return o;
817}
unsigned u32_t
Definition CommandLine.h:18
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition SVFType.h:576
#define DGENERAL
Definition SVFType.h:582
cJSON * p
Definition cJSON.cpp:2559
cJSON * item
Definition cJSON.h:222
virtual void expandFIObjs(const PointsTo &pts, PointsTo &expandedPts)
Expand FI objects.
const PointsTo & getPts(NodeID id) override
bool isGlobalObj() const
const FunObjVar * getFunction() const
Get function of this call node.
Definition CallGraph.h:191
const CallGraphNode * getCallGraphNode(const std::string &name) const
Get call graph node.
const RetICFGNode * getRetICFGNode() const
Return callsite.
Definition ICFGNode.h:440
const FunObjVar * getCaller() const
Return callsite.
Definition ICFGNode.h:453
bool push(const Data &data)
Definition WorkList.h:180
bool empty() const
Definition WorkList.h:161
BasicBlockGraph::IDToNodeMapTy::const_iterator const_bb_iterator
virtual const FunObjVar * getFunction() const
Get containing function, or null for globals/constants.
const_bb_iterator begin() const
bool isUncalledFunction() const
const_bb_iterator end() const
iterator begin()
Iterators.
IDToNodeMapTy::iterator iterator
Node Iterators.
GEdgeSetTy::iterator iterator
iterator InEdgeBegin()
iterator InEdgeEnd()
LoadsToMRsMap loadsToMRsMap
Map a load SVFIR Edge to its memory regions sets in order for inserting mus in Memory SSA.
Definition MemRegion.h:209
NodeToPTSSMap cachedPtsChainMap
Map a pointer to its cached points-to chain;.
Definition MemRegion.h:244
const NodeBS & getModSideEffectOfFunction(const FunObjVar *fun)
Get indirect mods of a function.
Definition MemRegion.h:412
bool hasModSideEffectOfCallSite(const CallICFGNode *cs)
Has indirect mods of a callsite.
Definition MemRegion.h:432
virtual void collectModRefForLoadStore()
Generate regions for loads/stores.
CallSiteToPointsToMap csToCallSiteRetPtsMap
Map a callsite to all its object might return from its callees.
Definition MemRegion.h:241
StoresToMRsMap storesToMRsMap
Map a store SVFIR Edge to its memory regions sets in order for inserting chis in Memory SSA.
Definition MemRegion.h:211
const NodeBS & getRefSideEffectOfFunction(const FunObjVar *fun)
Get indirect refs of a function.
Definition MemRegion.h:407
FunToPointsToMap funToModsMap
Map a function to its indirect defs of memory objects.
Definition MemRegion.h:233
virtual void refineCallsiteModRef(NodeBS &, NodeBS &, const CallICFGNode *, const FunObjVar *)
Definition MemRegion.h:344
CallSiteToPointsToMap callsiteToRefPointsToMap
Map a callsite to it refs cpts set.
Definition MemRegion.h:221
void addRefSideEffectOfFunction(const FunObjVar *fun, const NodeBS &refs)
Add/Get methods for side-effect of functions and callsites.
FunToMRsMap funToMRsMap
Map a function to all its memory regions.
Definition MemRegion.h:207
bool addUnfilteredModSideEffectOfCallSite(const CallICFGNode *cs, const NodeBS &mods)
Add indirect def to a callsite without applying call-argument filtering.
virtual bool handleCallsiteModRef(NodeBS &mod, NodeBS &ref, const CallICFGNode *cs, const FunObjVar *fun)
Get Mod-Ref of a callee function.
CallGraph * callGraph
Definition MemRegion.h:203
virtual void generateMRs()
Start generating memory regions.
virtual void collectModRefForCall()
Generate regions for calls/rets.
void createMR(const FunObjVar *fun, const NodeBS &cpts)
Generate a memory region and put in into functions which use it.
Definition MemRegion.cpp:70
virtual void propagateAdditionalModRef(CallGraphNode *, WorkList &)
Definition MemRegion.h:346
const MemRegion * getMR(const NodeBS &cpts) const
Get a memory region according to cpts.
Definition MemRegion.cpp:93
void addCPtsToLoad(NodeBS &cpts, const LoadStmt *ld, const FunObjVar *fun)
Definition MemRegion.h:357
FunToPointsTosMap & getFunToPointsToList()
Definition MemRegion.h:381
void addModSideEffectOfFunction(const FunObjVar *fun, const NodeBS &mods)
Add indirect def an memory object in the function.
CallSiteToPointsToMap csToModsMap
Map a callsite to its indirect defs of memory objects.
Definition MemRegion.h:237
virtual void sortPointsTo(const NodeBS &cpts)
Given a condition pts, insert into cptsToRepCPtsMap for region generation.
void addCPtsToStore(NodeBS &cpts, const StoreStmt *st, const FunObjVar *fun)
Add cpts to store/load.
Definition MemRegion.h:351
CallSiteToMRsMap callsiteToRefMRsMap
Map a callsite to its refs regions.
Definition MemRegion.h:213
virtual void getAliasMemRegions(MRSet &aliasMRs, const NodeBS &cpts, const FunObjVar *fun)
Get all aliased mem regions from function fun according to cpts.
Definition MemRegion.h:311
StoresToPointsToMap storesToPointsToMap
Map a store SVFIR Edge to its CPts set map.
Definition MemRegion.h:219
const FunObjVar * getFunction(const PAGEdge *pagEdge) const
Get the function which SVFIR Edge located.
Definition MemRegion.h:454
NodeBS & CollectPtsChain(NodeID id)
bool addRefSideEffectOfCallSite(const CallICFGNode *cs, const NodeBS &refs)
Add indirect uses an memory object in the function.
SVFIR::SVFStmtList SVFStmtList
SVFIR edge list.
Definition MemRegion.h:180
OrderedSet< NodeBS, SVFUtil::equalNodeBS > PointsToList
Definition MemRegion.h:147
bool addModSideEffectOfCallSite(const CallICFGNode *cs, const NodeBS &mods)
Add indirect def an memory object in the function.
void addCPtsToCallSiteRefs(NodeBS &cpts, const CallICFGNode *cs)
Definition MemRegion.h:363
NodeBS getRefInfoForCall(const CallICFGNode *cs)
bool hasRefSideEffectOfCallSite(const CallICFGNode *cs)
Has indirect refs of a callsite.
Definition MemRegion.h:427
OrderedSet< const MemRegion *, MemRegion::equalMemRegion > MRSet
Get typedef from Pointer Analysis.
Definition MemRegion.h:145
virtual void updateAliasMRs()
Update aliased regions for loads/stores/callsites.
void collectCallSitePts(const CallICFGNode *cs)
const NodeBS & getRepPointsTo(const NodeBS &cpts) const
Get superset cpts set.
Definition MemRegion.h:190
virtual void getMRsForCallSiteRef(MRSet &aliasMRs, const NodeBS &cpts, const FunObjVar *)
Get memory regions for call site ref according to cpts.
Definition MemRegion.h:328
bool hasSVFStmtList(const ICFGNode *icfgNode)
Whether this instruction has SVFIR Edge.
PAGEdgeToFunMap pagEdgeToFunMap
Map a PAGEdge to its fun.
Definition MemRegion.h:228
PtsToRepPtsSetMap cptsToRepCPtsMap
Map a condition pts to its rep conditional pts (super set points-to)
Definition MemRegion.h:282
void addCPtsToCallSiteMods(NodeBS &cpts, const CallICFGNode *cs)
Definition MemRegion.h:368
virtual void getMRsForLoad(MRSet &aliasMRs, const NodeBS &cpts, const FunObjVar *)
Get memory regions for a load statement according to cpts.
Definition MemRegion.h:321
CallSiteToPointsToMap callsiteToModPointsToMap
Map a callsite to it mods cpts set.
Definition MemRegion.h:223
SVFStmtList & getSVFStmtsFromInst(const ICFGNode *node)
Given an instruction, get all its the PAGEdge (statement) in sequence.
virtual void partitionMRs()
Partition regions.
ModRefInfo getModRefInfo(const CallICFGNode *cs)
void destroy()
Clean up memory.
Definition MemRegion.cpp:52
const NodeBS & getRefSideEffectOfCallSite(const CallICFGNode *cs)
Get indirect refs of a callsite.
Definition MemRegion.h:417
CallSiteToPointsToMap csToRefsMap
Map a callsite to its indirect uses of memory objects.
Definition MemRegion.h:235
MRGenerator(BVDataPTAImpl *p, bool ptrOnly)
Definition MemRegion.cpp:42
NodeBS & getCallSiteArgsPts(const CallICFGNode *cs)
Return the pts chain of all callsite arguments.
Definition MemRegion.h:259
bool isNonLocalObject(NodeID id, const FunObjVar *curFun) const
void getEscapObjviaGlobals(NodeBS &globs, const NodeBS &pts)
Get all the objects in callee's modref escaped via global objects (the chain pts of globals)
CallSiteToMRsMap callsiteToModMRsMap
Map a callsite to its mods regions.
Definition MemRegion.h:215
NodeBS getModInfoForCall(const CallICFGNode *cs)
getModRefInfo APIs
const NodeBS & getModSideEffectOfCallSite(const CallICFGNode *cs)
Get indirect mods of a callsite.
Definition MemRegion.h:422
SCCDetection< CallGraph * > SCC
Call Graph SCC.
Definition MemRegion.h:182
virtual void modRefAnalysis(CallGraphNode *callGraphNode, WorkList &worklist)
Mod-Ref analysis for callsite invoking this callGraphNode.
NodeBS & getCallSiteRetPts(const CallICFGNode *cs)
Return the pts chain of the return parameter of the callsite.
Definition MemRegion.h:264
NodeBS allGlobals
All global variable SVFIR node ids.
Definition MemRegion.h:247
LoadsToPointsToMap loadsToPointsToMap
Map a load SVFIR Edge to its CPts set map.
Definition MemRegion.h:217
FunToPointsToMap funToRefsMap
Map a function to its indirect uses of memory objects.
Definition MemRegion.h:231
MRSet memRegSet
A set of All memory regions.
Definition MemRegion.h:280
BVDataPTAImpl * pta
Definition MemRegion.h:201
void collectGlobals()
Collect all global variables for later escape analysis.
CallSiteToPointsToMap csToCallSiteArgsPtsMap
Map a callsite to all its object might pass into its callees.
Definition MemRegion.h:239
static u32_t totalVERNum
ver ID 0 is reserved
Definition MSSAMuChi.h:51
Memory Region class.
Definition MemRegion.h:60
static u32_t totalMRNum
region ID 0 is reserved
Definition MemRegion.h:66
static const Option< bool > IgnoreDeadFun
Definition Options.h:135
SVFIR * getPAG() const
CallGraph * getCallGraph() const
Return call graph.
NodeBS toNodeBS() const
Returns this points-to set as a NodeBS.
Definition PointsTo.cpp:313
const std::vector< const ICFGNode * > & getICFGNodeList() const
const CallSiteSet & getCallSiteSet() const
Get all callsites.
Definition SVFIR.h:351
bool hasPTASVFStmtList(const ICFGNode *inst) const
Definition SVFIR.h:312
NodeID getBaseObjVarID(NodeID id) const
Base and Offset methods for Value and Object node.
Definition SVFIR.h:554
const ValVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
Definition SVFIR.h:407
NodeBS getFieldsAfterCollapse(NodeID id)
Definition SVFIR.cpp:595
std::vector< const ValVar * > ValVarList
Definition SVFIR.h:60
SVFStmtList & getSVFStmtList(const ICFGNode *inst)
Given an instruction, get all its PAGEdges.
Definition SVFIR.h:318
bool hasSVFStmtList(const ICFGNode *inst) const
Whether this instruction has SVFIR Edge.
Definition SVFIR.h:308
std::vector< const SVFStmt * > SVFStmtList
Definition SVFIR.h:59
const BaseObjVar * getBaseObject(NodeID id) const
Definition SVFIR.h:498
const CallGraph * getCallGraph()
Get CG.
Definition SVFIR.h:248
bool hasCallSiteArgsMap(const CallICFGNode *cs) const
Callsite has argument list.
Definition SVFIR.h:385
bool callsiteHasRet(const RetICFGNode *cs) const
Definition SVFIR.h:413
SVFStmtList & getPTASVFStmtList(const ICFGNode *inst)
Given an instruction, get all its PTA PAGEdges.
Definition SVFIR.h:323
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:120
const ValVarList & getCallSiteArgsList(const CallICFGNode *cs) const
Get callsite argument list.
Definition SVFIR.h:395
NodeID getId() const
Get ID.
Definition SVFValue.h:158
virtual bool isPointer() const
Check if this variable represents a pointer.
bool test(unsigned Idx) const
void set(unsigned Idx)
bool contains(const SparseBitVector< ElementSize > &RHS) const
iterator begin() const
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
Definition SVFUtil.cpp:105
bool isHeapAllocExtCall(const ICFGNode *cs)
Definition SVFUtil.cpp:361
bool isExtCall(const FunObjVar *fun)
Definition SVFUtil.cpp:441
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52
for isBitcode
Definition BasicTypes.h:70
ModRefInfo
Definition SVFType.h:611
@ Ref
Definition SVFType.h:613
@ NoModRef
Definition SVFType.h:615
@ ModRef
Definition SVFType.h:612
@ Mod
Definition SVFType.h:614
u32_t NodeID
Definition GeneralType.h:76
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76
IntervalValue operator<<(const IntervalValue &lhs, const IntervalValue &rhs)
Left binary shift of IntervalValues.