Static Value-Flow Analysis
Public Types | Public Member Functions | Static Public Member Functions | List of all members
SVF::BVDataPTAImpl Class Reference

#include <PointerAnalysisImpl.h>

Inheritance diagram for SVF::BVDataPTAImpl:
SVF::PointerAnalysis SVF::AndersenBase SVF::CFLBase SVF::FlowDDA SVF::FlowSensitive SVF::Andersen SVF::Steensgaard SVF::TypeAnalysis SVF::CFLAlias SVF::CFLVF SVF::VersionedFlowSensitive SVF::AndersenSCD SVF::AndersenWaveDiff SVF::POCRAlias SVF::POCRHybrid SVF::AndersenSFR

Public Types

enum  PTBackingType { Mutable , Persistent }
 How the PTData used is implemented. More...
 
typedef PTData< NodeID, NodeSet, NodeID, PointsToPTDataTy
 
typedef DiffPTData< NodeID, NodeSet, NodeID, PointsToDiffPTDataTy
 
typedef DFPTData< NodeID, NodeSet, NodeID, PointsToDFPTDataTy
 
typedef VersionedPTData< NodeID, NodeSet, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > VersionedPTDataTy
 
typedef MutablePTData< NodeID, NodeSet, NodeID, PointsToMutPTDataTy
 
typedef MutableDiffPTData< NodeID, NodeSet, NodeID, PointsToMutDiffPTDataTy
 
typedef MutableDFPTData< NodeID, NodeSet, NodeID, PointsToMutDFPTDataTy
 
typedef MutableIncDFPTData< NodeID, NodeSet, NodeID, PointsToMutIncDFPTDataTy
 
typedef MutableVersionedPTData< NodeID, NodeSet, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > MutVersionedPTDataTy
 
typedef PersistentPTData< NodeID, NodeSet, NodeID, PointsToPersPTDataTy
 
typedef PersistentDiffPTData< NodeID, NodeSet, NodeID, PointsToPersDiffPTDataTy
 
typedef PersistentDFPTData< NodeID, NodeSet, NodeID, PointsToPersDFPTDataTy
 
typedef PersistentIncDFPTData< NodeID, NodeSet, NodeID, PointsToPersIncDFPTDataTy
 
typedef PersistentVersionedPTData< NodeID, NodeSet, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > PersVersionedPTDataTy
 
- Public Types inherited from SVF::PointerAnalysis
enum  PTATY {
  Andersen_BASE , Andersen_WPA , AndersenSCD_WPA , AndersenSFR_WPA ,
  AndersenWaveDiff_WPA , Steensgaard_WPA , CSCallString_WPA , CSSummary_WPA ,
  FSDATAFLOW_WPA , FSSPARSE_WPA , VFS_WPA , FSCS_WPA ,
  CFLFICI_WPA , CFLFSCI_WPA , CFLFSCS_WPA , TypeCPP_WPA ,
  FieldS_DDA , FlowS_DDA , PathS_DDA , Cxt_DDA ,
  Default_PTA
}
 Pointer analysis type list. More...
 
enum  PTAImplTy { BaseImpl , BVDataImpl , CondImpl }
 Implementation type: BVDataPTAImpl or CondPTAImpl. More...
 
typedef Set< const CallICFGNode * > CallSiteSet
 Indirect call edges type, map a callsite to a set of callees. More...
 
typedef SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap
 
typedef Set< const SVFFunction * > FunctionSet
 
typedef OrderedMap< const CallICFGNode *, FunctionSetCallEdgeMap
 
typedef SCCDetection< PTACallGraph * > CallGraphSCC
 
typedef Set< const SVFGlobalValue * > VTableSet
 
typedef Set< const SVFFunction * > VFunSet
 

Public Member Functions

 BVDataPTAImpl (SVFIR *pag, PointerAnalysis::PTATY type, bool alias_check=true)
 Constructor. More...
 
 ~BVDataPTAImpl () override=default
 Destructor. More...
 
PersistentPointsToCache< PointsTo > & getPtCache ()
 
- Public Member Functions inherited from SVF::PointerAnalysis
ICFGgetICFG () const
 Get ICFG. More...
 
u32_t getNumOfResolvedIndCallEdge () const
 Return number of resolved indirect call edges. More...
 
PTACallGraphgetCallGraph () const
 Return call graph. More...
 
CallGraphSCCgetCallGraphSCC () const
 Return call graph SCC. More...
 
 PointerAnalysis (SVFIR *pag, PTATY ty=Default_PTA, bool alias_check=true)
 Constructor. More...
 
PTATY getAnalysisTy () const
 Type of pointer analysis. More...
 
PTAImplTy getImplTy () const
 Return implementation type of the pointer analysis. More...
 
bool printStat ()
 Whether print statistics. More...
 
void disablePrintStat ()
 Whether print statistics. More...
 
CallEdgeMapgetIndCallMap ()
 Get callees from an indirect callsite. More...
 
bool hasIndCSCallees (const CallICFGNode *cs) const
 
const FunctionSetgetIndCSCallees (const CallICFGNode *cs) const
 
virtual void resolveIndCalls (const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
 Resolve indirect call edges. More...
 
void callGraphSCCDetection ()
 PTACallGraph SCC related methods. More...
 
NodeID getCallGraphSCCRepNode (NodeID id) const
 Get SCC rep node of a SVFG node. More...
 
bool inSameCallGraphSCC (const SVFFunction *fun1, const SVFFunction *fun2)
 Return TRUE if this edge is inside a PTACallGraph SCC, i.e., src node and dst node are in the same SCC on the SVFG. More...
 
bool isInRecursion (const SVFFunction *fun) const
 
bool isLocalVarInRecursiveFun (NodeID id) const
 Whether a local variable is in function recursions. More...
 
virtual const std::string PTAName () const
 Return PTA name. More...
 
CommonCHGraphgetCHGraph () const
 get CHGraph More...
 
void getVFnsFromCHA (const CallICFGNode *cs, VFunSet &vfns)
 
void getVFnsFromPts (const CallICFGNode *cs, const PointsTo &target, VFunSet &vfns)
 
void connectVCallToVFns (const CallICFGNode *cs, const VFunSet &vfns, CallEdgeMap &newEdges)
 
virtual void resolveCPPIndCalls (const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
 Resolve cpp indirect call edges. More...
 
SVFIRgetPAG () const
 
PTAStatgetStat () const
 Get PTA stat. More...
 
SVFModulegetModule () const
 Module. More...
 
OrderedNodeSetgetAllValidPtrs ()
 Get all Valid Pointers for resolution. More...
 
virtual ~PointerAnalysis ()
 Destructor. More...
 
virtual void initialize ()
 Initialization of a pointer analysis, including building symbol table and SVFIR etc. More...
 
virtual void analyze ()=0
 Start Analysis here (main part of pointer analysis). It needs to be implemented in child class. More...
 
virtual void computeDDAPts (NodeID)
 Compute points-to results on-demand, overridden by derived classes. More...
 
void printIndCSTargets (const CallICFGNode *cs, const FunctionSet &targets)
 Print targets of a function pointer. More...
 
virtual void dumpPts (NodeID ptr, const PointsTo &pts)
 
void printIndCSTargets ()
 
void dumpAllTypes ()
 
void dumpStat ()
 Dump the statistics. More...
 
bool containBlackHoleNode (const PointsTo &pts)
 Determine whether a points-to contains a black hole or constant node. More...
 
bool containConstantNode (const PointsTo &pts)
 
virtual bool isBlkObjOrConstantObj (NodeID ptd) const
 
bool isHeapMemObj (NodeID id) const
 Whether this object is heap or array. More...
 
bool isArrayMemObj (NodeID id) const
 
bool isFIObjNode (NodeID id) const
 
NodeID getBaseObjVar (NodeID id)
 
NodeID getFIObjVar (NodeID id)
 
NodeID getGepObjVar (NodeID id, const APOffset &ap)
 
virtual const NodeBSgetAllFieldsObjVars (NodeID id)
 
void setObjFieldInsensitive (NodeID id)
 
bool isFieldInsensitive (NodeID id) const
 

Static Public Member Functions

static bool classof (const PointerAnalysis *pta)
 
std::unique_ptr< PTDataTyptD
 Points-to data. More...
 
PersistentPointsToCache< PointsToptCache
 
const PointsTogetPts (NodeID id) override
 
const NodeSetgetRevPts (NodeID nodeId) override
 
virtual void clearPts (NodeID id, NodeID element)
 Remove element from the points-to set of id. More...
 
virtual void clearFullPts (NodeID id)
 Clear points-to set of id. More...
 
virtual bool unionPts (NodeID id, const PointsTo &target)
 
virtual bool unionPts (NodeID id, NodeID ptd)
 
virtual bool addPts (NodeID id, NodeID ptd)
 
virtual void clearAllPts ()
 Clear all data. More...
 
virtual void expandFIObjs (const PointsTo &pts, PointsTo &expandedPts)
 Expand FI objects. More...
 
virtual void expandFIObjs (const NodeBS &pts, NodeBS &expandedPts)
 TODO: remove repetition. More...
 
void remapPointsToSets (void)
 Remap all points-to sets to use the current mapping. More...
 
virtual void writeToFile (const std::string &filename)
 Interface for analysis result storage on filesystem. More...
 
virtual void writeObjVarToFile (const std::string &filename)
 
virtual void writePtsResultToFile (std::fstream &f)
 
virtual void writeGepObjVarMapToFile (std::fstream &f)
 
virtual bool readFromFile (const std::string &filename)
 
virtual void readPtsResultFromFile (std::ifstream &f)
 
virtual void readGepObjVarMapFromFile (std::ifstream &f)
 
virtual void readAndSetObjFieldSensitivity (std::ifstream &f, const std::string &delimiterStr)
 
AliasResult alias (const SVFValue *V1, const SVFValue *V2) override
 Interface expose to users of our pointer analysis, given Value infos. More...
 
AliasResult alias (NodeID node1, NodeID node2) override
 Interface expose to users of our pointer analysis, given PAGNodeID. More...
 
virtual AliasResult alias (const PointsTo &pts1, const PointsTo &pts2)
 Interface expose to users of our pointer analysis, given two pts. More...
 
void dumpCPts () override
 dump and debug, print out conditional pts More...
 
void dumpTopLevelPtsTo () override
 
void dumpAllPts () override
 
PTDataTygetPTDataTy () const
 Get points-to data structure. More...
 
void finalize () override
 Finalization of pointer analysis, and normalize points-to information to Bit Vector representation. More...
 
virtual bool updateCallGraph (const CallSiteToFunPtrMap &)
 Update callgraph. This should be implemented by its subclass. More...
 
DiffPTDataTygetDiffPTDataTy () const
 
DFPTDataTygetDFPTDataTy () const
 
MutDFPTDataTygetMutDFPTDataTy () const
 
VersionedPTDataTygetVersionedPTDataTy () const
 
virtual void onTheFlyCallGraphSolve (const CallSiteToFunPtrMap &callsites, CallEdgeMap &newEdges)
 On the fly call graph construction. More...
 
virtual void onTheFlyThreadCallGraphSolve (const CallSiteToFunPtrMap &callsites, CallEdgeMap &newForkEdges)
 On the fly thread call graph construction respecting forksite. More...
 
virtual void normalizePointsTo ()
 

Additional Inherited Members

- Static Public Attributes inherited from SVF::PointerAnalysis
static const std::string aliasTestMayAlias = "MAYALIAS"
 
static const std::string aliasTestMayAliasMangled = "_Z8MAYALIASPvS_"
 
static const std::string aliasTestNoAlias = "NOALIAS"
 
static const std::string aliasTestNoAliasMangled = "_Z7NOALIASPvS_"
 
static const std::string aliasTestPartialAlias = "PARTIALALIAS"
 
static const std::string aliasTestPartialAliasMangled = "_Z12PARTIALALIASPvS_"
 
static const std::string aliasTestMustAlias = "MUSTALIAS"
 
static const std::string aliasTestMustAliasMangled = "_Z9MUSTALIASPvS_"
 
static const std::string aliasTestFailMayAlias = "EXPECTEDFAIL_MAYALIAS"
 
static const std::string aliasTestFailMayAliasMangled = "_Z21EXPECTEDFAIL_MAYALIASPvS_"
 
static const std::string aliasTestFailNoAlias = "EXPECTEDFAIL_NOALIAS"
 
static const std::string aliasTestFailNoAliasMangled = "_Z20EXPECTEDFAIL_NOALIASPvS_"
 
- Protected Member Functions inherited from SVF::PointerAnalysis
const CallSiteToFunPtrMapgetIndirectCallsites () const
 Return all indirect callsites. More...
 
NodeID getFunPtr (const CallICFGNode *cs) const
 Return function pointer PAGNode at a callsite cs. More...
 
virtual void validateTests ()
 Alias check functions to verify correctness of pointer analysis. More...
 
virtual void validateSuccessTests (std::string fun)
 
virtual void validateExpectedFailureTests (std::string fun)
 
void resetObjFieldSensitive ()
 Reset all object node as field-sensitive. More...
 
- Protected Attributes inherited from SVF::PointerAnalysis
bool print_stat
 User input flags. More...
 
bool alias_validation
 Flag for validating points-to/alias results. More...
 
u32_t OnTheFlyIterBudgetForStat
 Flag for iteration budget for on-the-fly statistics. More...
 
SVFModulesvfMod
 Module. More...
 
PTATY ptaTy
 Pointer analysis Type. More...
 
PTAImplTy ptaImplTy
 PTA implementation type. More...
 
PTAStatstat
 Statistics. More...
 
PTACallGraphcallgraph
 Call graph used for pointer analysis. More...
 
CallGraphSCCcallGraphSCC
 SCC for PTACallGraph. More...
 
ICFGicfg
 Interprocedural control-flow graph. More...
 
CommonCHGraphchgraph
 CHGraph. More...
 
- Static Protected Attributes inherited from SVF::PointerAnalysis
static SVFIRpag = nullptr
 SVFIR. More...
 

Detailed Description

Pointer analysis implementation which uses bit vector based points-to data structure

Definition at line 42 of file PointerAnalysisImpl.h.

Member Typedef Documentation

◆ DFPTDataTy

Definition at line 48 of file PointerAnalysisImpl.h.

◆ DiffPTDataTy

Definition at line 47 of file PointerAnalysisImpl.h.

◆ MutDFPTDataTy

Definition at line 53 of file PointerAnalysisImpl.h.

◆ MutDiffPTDataTy

Definition at line 52 of file PointerAnalysisImpl.h.

◆ MutIncDFPTDataTy

Definition at line 54 of file PointerAnalysisImpl.h.

◆ MutPTDataTy

Definition at line 51 of file PointerAnalysisImpl.h.

◆ MutVersionedPTDataTy

Definition at line 55 of file PointerAnalysisImpl.h.

◆ PersDFPTDataTy

Definition at line 59 of file PointerAnalysisImpl.h.

◆ PersDiffPTDataTy

Definition at line 58 of file PointerAnalysisImpl.h.

◆ PersIncDFPTDataTy

Definition at line 60 of file PointerAnalysisImpl.h.

◆ PersPTDataTy

Definition at line 57 of file PointerAnalysisImpl.h.

◆ PersVersionedPTDataTy

Definition at line 61 of file PointerAnalysisImpl.h.

◆ PTDataTy

Definition at line 46 of file PointerAnalysisImpl.h.

◆ VersionedPTDataTy

Definition at line 49 of file PointerAnalysisImpl.h.

Member Enumeration Documentation

◆ PTBackingType

How the PTData used is implemented.

Enumerator
Mutable 
Persistent 

Definition at line 64 of file PointerAnalysisImpl.h.

Constructor & Destructor Documentation

◆ BVDataPTAImpl()

BVDataPTAImpl::BVDataPTAImpl ( SVFIR p,
PointerAnalysis::PTATY  type,
bool  alias_check = true 
)

Constructor.

Constructor

Definition at line 44 of file PointerAnalysisImpl.cpp.

44  :
45  PointerAnalysis(p, type, alias_check), ptCache()
46 {
48  || type == TypeCPP_WPA || type == FlowS_DDA
50  {
51  // Only maintain reverse points-to when the analysis is field-sensitive, as objects turning
52  // field-insensitive is all it is used for.
53  bool maintainRevPts = Options::MaxFieldLimit() != 0;
54  if (Options::ptDataBacking() == PTBackingType::Mutable) ptD = std::make_unique<MutDiffPTDataTy>(maintainRevPts);
55  else if (Options::ptDataBacking() == PTBackingType::Persistent) ptD = std::make_unique<PersDiffPTDataTy>(getPtCache(), maintainRevPts);
56  else assert(false && "BVDataPTAImpl::BVDataPTAImpl: unexpected points-to backing type!");
57  }
58  else if (type == Steensgaard_WPA)
59  {
60  // Steensgaard is only field-insensitive (for now?), so no reverse points-to.
61  if (Options::ptDataBacking() == PTBackingType::Mutable) ptD = std::make_unique<MutDiffPTDataTy>(false);
62  else if (Options::ptDataBacking() == PTBackingType::Persistent) ptD = std::make_unique<PersDiffPTDataTy>(getPtCache(), false);
63  else assert(false && "BVDataPTAImpl::BVDataPTAImpl: unexpected points-to backing type!");
64  }
65  else if (type == FSSPARSE_WPA)
66  {
68  {
69  if (Options::ptDataBacking() == PTBackingType::Mutable) ptD = std::make_unique<MutIncDFPTDataTy>(false);
70  else if (Options::ptDataBacking() == PTBackingType::Persistent) ptD = std::make_unique<PersIncDFPTDataTy>(getPtCache(), false);
71  else assert(false && "BVDataPTAImpl::BVDataPTAImpl: unexpected points-to backing type!");
72  }
73  else
74  {
75  if (Options::ptDataBacking() == PTBackingType::Mutable) ptD = std::make_unique<MutDFPTDataTy>(false);
76  else if (Options::ptDataBacking() == PTBackingType::Persistent) ptD = std::make_unique<PersDFPTDataTy>(getPtCache(), false);
77  else assert(false && "BVDataPTAImpl::BVDataPTAImpl: unexpected points-to backing type!");
78  }
79  }
80  else if (type == VFS_WPA)
81  {
82  if (Options::ptDataBacking() == PTBackingType::Mutable) ptD = std::make_unique<MutVersionedPTDataTy>(false);
83  else if (Options::ptDataBacking() == PTBackingType::Persistent) ptD = std::make_unique<PersVersionedPTDataTy>(getPtCache(), false);
84  else assert(false && "BVDataPTAImpl::BVDataPTAImpl: unexpected points-to backing type!");
85  }
86  else assert(false && "no points-to data available");
87 
89 }
cJSON * p
Definition: cJSON.cpp:2559
newitem type
Definition: cJSON.cpp:2739
PersistentPointsToCache< PointsTo > ptCache
std::unique_ptr< PTDataTy > ptD
Points-to data.
PersistentPointsToCache< PointsTo > & getPtCache()
static const Option< bool > INCDFPTData
Definition: Options.h:136
static const Option< u32_t > MaxFieldLimit
Maximum number of field derivations for an object.
Definition: Options.h:38
static const OptionMap< BVDataPTAImpl::PTBackingType > ptDataBacking
PTData type.
Definition: Options.h:69
@ CFLFICI_WPA
Flow-, context-, insensitive CFL-reachability-based analysis.
@ VFS_WPA
Versioned sparse flow-sensitive WPA.
@ AndersenSCD_WPA
Selective cycle detection andersen-style WPA.
@ Andersen_BASE
Base Andersen PTA.
@ FlowS_DDA
Flow sensitive DDA.
@ Andersen_WPA
Andersen PTA.
@ CFLFSCS_WPA
Flow-, context-, CFL-reachability-based analysis.
@ AndersenWaveDiff_WPA
Diff wave propagation andersen-style WPA.
@ TypeCPP_WPA
Type-based analysis for C++.
@ AndersenSFR_WPA
Stride-based field representation.
@ Steensgaard_WPA
Steensgaard PTA.
@ FSSPARSE_WPA
Sparse flow sensitive WPA.
PointerAnalysis(SVFIR *pag, PTATY ty=Default_PTA, bool alias_check=true)
Constructor.
PTAImplTy ptaImplTy
PTA implementation type.
@ BVDataImpl
Represents BVDataPTAImpl.

◆ ~BVDataPTAImpl()

SVF::BVDataPTAImpl::~BVDataPTAImpl ( )
overridedefault

Destructor.

Member Function Documentation

◆ addPts()

virtual bool SVF::BVDataPTAImpl::addPts ( NodeID  id,
NodeID  ptd 
)
inlinevirtual

Definition at line 121 of file PointerAnalysisImpl.h.

122  {
123  return ptD->addPts(id,ptd);
124  }

◆ alias() [1/3]

AliasResult BVDataPTAImpl::alias ( const PointsTo p1,
const PointsTo p2 
)
virtual

Interface expose to users of our pointer analysis, given two pts.

Return alias results based on our points-to/alias analysis

Definition at line 626 of file PointerAnalysisImpl.cpp.

627 {
628 
629  PointsTo pts1;
630  expandFIObjs(p1,pts1);
631  PointsTo pts2;
632  expandFIObjs(p2,pts2);
633 
634  if (containBlackHoleNode(pts1) || containBlackHoleNode(pts2) || pts1.intersects(pts2))
635  return AliasResult::MayAlias;
636  else
637  return AliasResult::NoAlias;
638 }
virtual void expandFIObjs(const PointsTo &pts, PointsTo &expandedPts)
Expand FI objects.
bool containBlackHoleNode(const PointsTo &pts)
Determine whether a points-to contains a black hole or constant node.
bool intersects(const PointsTo &rhs) const
Returns true if this set and rhs share any elements.
Definition: PointsTo.cpp:189
@ MayAlias
Definition: SVFType.h:529
@ NoAlias
Definition: SVFType.h:528

◆ alias() [2/3]

AliasResult BVDataPTAImpl::alias ( const SVFValue V1,
const SVFValue V2 
)
overridevirtual

Interface expose to users of our pointer analysis, given Value infos.

Return alias results based on our points-to/alias analysis

Implements SVF::PointerAnalysis.

Definition at line 609 of file PointerAnalysisImpl.cpp.

611 {
612  return alias(pag->getValueNode(V1),pag->getValueNode(V2));
613 }
AliasResult alias(const SVFValue *V1, const SVFValue *V2) override
Interface expose to users of our pointer analysis, given Value infos.
NodeID getValueNode(const SVFValue *V)
Definition: IRGraph.h:137
static SVFIR * pag
SVFIR.

◆ alias() [3/3]

AliasResult BVDataPTAImpl::alias ( NodeID  node1,
NodeID  node2 
)
overridevirtual

Interface expose to users of our pointer analysis, given PAGNodeID.

Return alias results based on our points-to/alias analysis

Implements SVF::PointerAnalysis.

Definition at line 618 of file PointerAnalysisImpl.cpp.

619 {
620  return alias(getPts(node1),getPts(node2));
621 }
const PointsTo & getPts(NodeID id) override

◆ classof()

static bool SVF::BVDataPTAImpl::classof ( const PointerAnalysis pta)
inlinestatic

Definition at line 81 of file PointerAnalysisImpl.h.

82  {
83  return pta->getImplTy() == BVDataImpl;
84  }

◆ clearAllPts()

virtual void SVF::BVDataPTAImpl::clearAllPts ( )
inlinevirtual

Clear all data.

Definition at line 128 of file PointerAnalysisImpl.h.

129  {
130  ptD->clear();
131  }

◆ clearFullPts()

virtual void SVF::BVDataPTAImpl::clearFullPts ( NodeID  id)
inlinevirtual

Clear points-to set of id.

Definition at line 105 of file PointerAnalysisImpl.h.

106  {
107  ptD->clearFullPts(id);
108  }

◆ clearPts()

virtual void SVF::BVDataPTAImpl::clearPts ( NodeID  id,
NodeID  element 
)
inlinevirtual

Remove element from the points-to set of id.

Definition at line 99 of file PointerAnalysisImpl.h.

100  {
101  ptD->clearPts(id, element);
102  }

◆ dumpAllPts()

void BVDataPTAImpl::dumpAllPts ( )
overridevirtual

Dump all points-to including top-level (ValVar) and address-taken (ObjVar) variables

Reimplemented from SVF::PointerAnalysis.

Definition at line 469 of file PointerAnalysisImpl.cpp.

470 {
471  OrderedNodeSet pagNodes;
472  for(SVFIR::iterator it = pag->begin(), eit = pag->end(); it!=eit; it++)
473  {
474  pagNodes.insert(it->first);
475  }
476 
477  for (NodeID n : pagNodes)
478  {
479  outs() << "----------------------------------------------\n";
480  dumpPts(n, this->getPts(n));
481  }
482 
483  outs() << "----------------------------------------------\n";
484 }
cJSON * n
Definition: cJSON.cpp:2558
iterator begin()
Iterators.
Definition: GenericGraph.h:627
IDToNodeMapTy::iterator iterator
Node Iterators.
Definition: GenericGraph.h:606
virtual void dumpPts(NodeID ptr, const PointsTo &pts)
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50
OrderedSet< NodeID > OrderedNodeSet
Definition: GeneralType.h:112
u32_t NodeID
Definition: GeneralType.h:55

◆ dumpCPts()

void SVF::BVDataPTAImpl::dumpCPts ( )
inlineoverridevirtual

dump and debug, print out conditional pts

Reimplemented from SVF::PointerAnalysis.

Definition at line 229 of file PointerAnalysisImpl.h.

230  {
231  ptD->dumpPTData();
232  }

◆ dumpTopLevelPtsTo()

void BVDataPTAImpl::dumpTopLevelPtsTo ( )
overridevirtual

Dump points-to of each pag node

Reimplemented from SVF::PointerAnalysis.

Reimplemented in SVF::Andersen.

Definition at line 436 of file PointerAnalysisImpl.cpp.

437 {
438  for (OrderedNodeSet::iterator nIter = this->getAllValidPtrs().begin();
439  nIter != this->getAllValidPtrs().end(); ++nIter)
440  {
441  const PAGNode* node = getPAG()->getGNode(*nIter);
442  if (getPAG()->isValidTopLevelPtr(node))
443  {
444  const PointsTo& pts = this->getPts(node->getId());
445  outs() << "\nNodeID " << node->getId() << " ";
446 
447  if (pts.empty())
448  {
449  outs() << "\t\tPointsTo: {empty}\n\n";
450  }
451  else
452  {
453  outs() << "\t\tPointsTo: { ";
454  for (PointsTo::iterator it = pts.begin(), eit = pts.end();
455  it != eit; ++it)
456  outs() << *it << " ";
457  outs() << "}\n\n";
458  }
459  }
460  }
461 
462  outs().flush();
463 }
NodeType * getGNode(NodeID id) const
Get a node.
Definition: GenericGraph.h:653
SVFIR * getPAG() const
OrderedNodeSet & getAllValidPtrs()
Get all Valid Pointers for resolution.
bool empty() const
Returns true if set is empty.
Definition: PointsTo.cpp:98
const_iterator end() const
Definition: PointsTo.h:132
const_iterator begin() const
Definition: PointsTo.h:128
NodeID getId() const
Get ID.
Definition: GenericGraph.h:260

◆ expandFIObjs() [1/2]

void BVDataPTAImpl::expandFIObjs ( const NodeBS pts,
NodeBS expandedPts 
)
virtual

TODO: remove repetition.

Definition at line 143 of file PointerAnalysisImpl.cpp.

144 {
145  expandedPts = pts;
146  for (const NodeID o : pts)
147  {
148  if (pag->getBaseObjVar(o) == o || isFieldInsensitive(o))
149  {
150  expandedPts |= pag->getAllFieldsObjVars(o);
151  }
152  }
153 }
bool isFieldInsensitive(NodeID id) const
NodeBS & getAllFieldsObjVars(const MemObj *obj)
Get all fields of an object.
Definition: SVFIR.cpp:477
NodeID getBaseObjVar(NodeID id) const
Base and Offset methods for Value and Object node.
Definition: SVFIR.h:455

◆ expandFIObjs() [2/2]

void BVDataPTAImpl::expandFIObjs ( const PointsTo pts,
PointsTo expandedPts 
)
virtual

Expand FI objects.

Expand all fields of an aggregate in all points-to sets

Definition at line 131 of file PointerAnalysisImpl.cpp.

132 {
133  expandedPts = pts;;
134  for(PointsTo::iterator pit = pts.begin(), epit = pts.end(); pit!=epit; ++pit)
135  {
136  if (pag->getBaseObjVar(*pit) == *pit || isFieldInsensitive(*pit))
137  {
138  expandedPts |= pag->getAllFieldsObjVars(*pit);
139  }
140  }
141 }

◆ finalize()

void BVDataPTAImpl::finalize ( )
overrideprotectedvirtual

Finalization of pointer analysis, and normalize points-to information to Bit Vector representation.

Reimplemented from SVF::PointerAnalysis.

Reimplemented in SVF::VersionedFlowSensitive, SVF::TypeAnalysis, SVF::FlowSensitive, SVF::AndersenBase, and SVF::Andersen.

Definition at line 91 of file PointerAnalysisImpl.cpp.

92 {
95 
96  if (Options::ptDataBacking() == PTBackingType::Persistent && print_stat)
97  {
98  std::string moduleName(pag->getModule()->getModuleIdentifier());
99  std::vector<std::string> names = SVFUtil::split(moduleName,'/');
100  if (names.size() > 1)
101  moduleName = names[names.size() - 1];
102 
103  std::string subtitle;
104 
106  subtitle = "Andersen's analysis bitvector";
107  else if(ptaTy >=FSDATAFLOW_WPA && ptaTy <=FSCS_WPA)
108  subtitle = "flow-sensitive analysis bitvector";
109  else if(ptaTy >=CFLFICI_WPA && ptaTy <=CFLFSCS_WPA)
110  subtitle = "CFL analysis bitvector";
111  else if(ptaTy == TypeCPP_WPA)
112  subtitle = "Type analysis bitvector";
113  else if(ptaTy >=FieldS_DDA && ptaTy <=Cxt_DDA)
114  subtitle = "DDA bitvector";
115  else
116  subtitle = "bitvector";
117 
118  SVFUtil::outs() << "\n****Persistent Points-To Cache Statistics: " << subtitle << "****\n";
119  SVFUtil::outs() << "################ (program : " << moduleName << ")###############\n";
120  SVFUtil::outs().flags(std::ios::left);
121  ptCache.printStats("bitvector");
122  SVFUtil::outs() << "#######################################################" << std::endl;
123  SVFUtil::outs().flush();
124  }
125 
126 }
const char *const string
Definition: cJSON.h:172
virtual void normalizePointsTo()
@ Cxt_DDA
context sensitive DDA
@ FSCS_WPA
Flow-, context- sensitive WPA.
@ FSDATAFLOW_WPA
Traditional Dataflow-based flow sensitive WPA.
@ FieldS_DDA
Field sensitive DDA.
virtual void finalize()
Finalization of a pointer analysis, including checking alias correctness.
bool print_stat
User input flags.
PTATY ptaTy
Pointer analysis Type.
SVFModule * getModule()
Definition: SVFIR.h:161
const std::string & getModuleIdentifier() const
Definition: SVFModule.h:185
std::vector< std::string > split(const std::string &s, char separator)
Split into two substrings around the first occurrence of a separator string.
Definition: SVFUtil.h:203

◆ getDFPTDataTy()

DFPTDataTy* SVF::BVDataPTAImpl::getDFPTDataTy ( ) const
inlineprotected

Definition at line 178 of file PointerAnalysisImpl.h.

179  {
180  DFPTDataTy* df = SVFUtil::dyn_cast<DFPTDataTy>(ptD.get());
181  assert(df && "BVDataPTAImpl::getDFPTDataTy: not a DFPTDataTy!");
182  return df;
183  }
DFPTData< NodeID, NodeSet, NodeID, PointsTo > DFPTDataTy

◆ getDiffPTDataTy()

DiffPTDataTy* SVF::BVDataPTAImpl::getDiffPTDataTy ( ) const
inlineprotected

Definition at line 171 of file PointerAnalysisImpl.h.

172  {
173  DiffPTDataTy* diff = SVFUtil::dyn_cast<DiffPTDataTy>(ptD.get());
174  assert(diff && "BVDataPTAImpl::getDiffPTDataTy: not a DiffPTDataTy!");
175  return diff;
176  }
DiffPTData< NodeID, NodeSet, NodeID, PointsTo > DiffPTDataTy

◆ getMutDFPTDataTy()

MutDFPTDataTy* SVF::BVDataPTAImpl::getMutDFPTDataTy ( ) const
inlineprotected

Definition at line 185 of file PointerAnalysisImpl.h.

186  {
187  MutDFPTDataTy* mdf = SVFUtil::dyn_cast<MutDFPTDataTy>(ptD.get());
188  assert(mdf && "BVDataPTAImpl::getMutDFPTDataTy: not a MutDFPTDataTy!");
189  return mdf;
190  }
MutableDFPTData< NodeID, NodeSet, NodeID, PointsTo > MutDFPTDataTy

◆ getPtCache()

PersistentPointsToCache<PointsTo>& SVF::BVDataPTAImpl::getPtCache ( )
inline

Definition at line 76 of file PointerAnalysisImpl.h.

77  {
78  return ptCache;
79  }

◆ getPTDataTy()

PTDataTy* SVF::BVDataPTAImpl::getPTDataTy ( ) const
inlineprotected

Get points-to data structure.

Definition at line 155 of file PointerAnalysisImpl.h.

156  {
157  return ptD.get();
158  }

◆ getPts()

const PointsTo& SVF::BVDataPTAImpl::getPts ( NodeID  id)
inlineoverridevirtual

Get points-to and reverse points-to

Implements SVF::PointerAnalysis.

Reimplemented in SVF::Steensgaard, and SVF::Andersen.

Definition at line 88 of file PointerAnalysisImpl.h.

89  {
90  return ptD->getPts(id);
91  }

◆ getRevPts()

const NodeSet& SVF::BVDataPTAImpl::getRevPts ( NodeID  nodeId)
inlineoverridevirtual

Given an object, get all the nodes having whose pointsto contains the object. Similar to getPts, this also needs to be implemented in child classes.

Implements SVF::PointerAnalysis.

Definition at line 92 of file PointerAnalysisImpl.h.

93  {
94  return ptD->getRevPts(nodeId);
95  }

◆ getVersionedPTDataTy()

VersionedPTDataTy* SVF::BVDataPTAImpl::getVersionedPTDataTy ( ) const
inlineprotected

Definition at line 192 of file PointerAnalysisImpl.h.

193  {
194  VersionedPTDataTy* v = SVFUtil::dyn_cast<VersionedPTDataTy>(ptD.get());
195  assert(v && "BVDataPTAImpl::getVersionedPTDataTy: not a VersionedPTDataTy!");
196  return v;
197  }
VersionedPTData< NodeID, NodeSet, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > VersionedPTDataTy

◆ normalizePointsTo()

void BVDataPTAImpl::normalizePointsTo ( )
protectedvirtual

Normalize points-to information for field-sensitive analysis, i.e., replace fieldObj with baseObj if it is field-insensitive

Normalize points-to information for field-sensitive analysis

Reimplemented in SVF::AndersenBase.

Definition at line 550 of file PointerAnalysisImpl.cpp.

551 {
552  SVFIR::MemObjToFieldsMap &memToFieldsMap = pag->getMemToFieldsMap();
553  SVFIR::NodeOffsetMap &GepObjVarMap = pag->getGepObjNodeMap();
554 
555  // collect each gep node whose base node has been set as field-insensitive
556  NodeBS dropNodes;
557  for (auto t: memToFieldsMap)
558  {
559  NodeID base = t.first;
560  const MemObj* memObj = pag->getObject(base);
561  assert(memObj && "Invalid memobj in memToFieldsMap");
562  if (memObj->isFieldInsensitive())
563  {
564  for (NodeID id : t.second)
565  {
566  if (SVFUtil::isa<GepObjVar>(pag->getGNode(id)))
567  {
568  dropNodes.set(id);
569  }
570  else
571  assert(id == base && "Not a GepObj Node or a baseObj Node?");
572  }
573  }
574  }
575 
576  // remove the collected redundant gep nodes in each pointers's pts
577  for (SVFIR::iterator nIter = pag->begin(); nIter != pag->end(); ++nIter)
578  {
579  NodeID n = nIter->first;
580 
581  const PointsTo &tmpPts = getPts(n);
582  for (NodeID obj : tmpPts)
583  {
584  if (!dropNodes.test(obj))
585  continue;
586  NodeID baseObj = pag->getBaseObjVar(obj);
587  clearPts(n, obj);
588  addPts(n, baseObj);
589  }
590  }
591 
592  // clear GepObjVarMap and memToFieldsMap for redundant gepnodes
593  // and remove those nodes from pag
594  for (NodeID n: dropNodes)
595  {
596  NodeID base = pag->getBaseObjVar(n);
597  GepObjVar *gepNode = SVFUtil::dyn_cast<GepObjVar>(pag->getGNode(n));
598  const APOffset apOffset = gepNode->getConstantFieldIdx();
599  GepObjVarMap.erase(std::make_pair(base, apOffset));
600  memToFieldsMap[base].reset(n);
601 
602  pag->removeGNode(gepNode);
603  }
604 }
virtual void clearPts(NodeID id, NodeID element)
Remove element from the points-to set of id.
virtual bool addPts(NodeID id, NodeID ptd)
void removeGNode(NodeType *node)
Delete a node.
Definition: GenericGraph.h:668
APOffset getConstantFieldIdx() const
offset of the mem object
Definition: SVFVariables.h:500
bool isFieldInsensitive() const
Return true if its field limit is 0.
const MemObj * getObject(NodeID id) const
Definition: SVFIR.h:395
MemObjToFieldsMap & getMemToFieldsMap()
Return memToFieldsMap.
Definition: SVFIR.h:129
Map< NodeID, NodeBS > MemObjToFieldsMap
Definition: SVFIR.h:57
NodeOffsetMap & getGepObjNodeMap()
Return GepObjVarMap.
Definition: SVFIR.h:134
Map< NodeOffset, NodeID > NodeOffsetMap
Definition: SVFIR.h:70
bool test(unsigned Idx) const
void set(unsigned Idx)
s64_t APOffset
Definition: GeneralType.h:60

◆ onTheFlyCallGraphSolve()

void BVDataPTAImpl::onTheFlyCallGraphSolve ( const CallSiteToFunPtrMap callsites,
CallEdgeMap newEdges 
)
protectedvirtual

On the fly call graph construction.

On the fly call graph construction callsites is candidate indirect callsites need to be analyzed based on points-to results newEdges is the new indirect call edges discovered

Reimplemented in SVF::CFLAlias.

Definition at line 492 of file PointerAnalysisImpl.cpp.

493 {
494  for(CallSiteToFunPtrMap::const_iterator iter = callsites.begin(), eiter = callsites.end(); iter!=eiter; ++iter)
495  {
496  const CallICFGNode* cs = iter->first;
497 
498  if (cs->isVirtualCall())
499  {
500  const SVFVar* vtbl = cs->getVtablePtr();
501  assert(vtbl != nullptr);
502  NodeID vtblId = vtbl->getId();
503  resolveCPPIndCalls(cs, getPts(vtblId), newEdges);
504  }
505  else
506  resolveIndCalls(iter->first,getPts(iter->second),newEdges);
507  }
508 }
const SVFVar * getVtablePtr() const
Definition: ICFGNode.h:537
bool isVirtualCall() const
Definition: ICFGNode.h:527
virtual void resolveIndCalls(const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
Resolve indirect call edges.
virtual void resolveCPPIndCalls(const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
Resolve cpp indirect call edges.

◆ onTheFlyThreadCallGraphSolve()

void BVDataPTAImpl::onTheFlyThreadCallGraphSolve ( const CallSiteToFunPtrMap callsites,
CallEdgeMap newForkEdges 
)
protectedvirtual

On the fly thread call graph construction respecting forksite.

On the fly call graph construction respecting forksite callsites is candidate indirect callsites need to be analyzed based on points-to results newEdges is the new indirect call edges discovered

Definition at line 515 of file PointerAnalysisImpl.cpp.

517 {
518  // add indirect fork edges
519  if(ThreadCallGraph *tdCallGraph = SVFUtil::dyn_cast<ThreadCallGraph>(callgraph))
520  {
521  for(CallSiteSet::const_iterator it = tdCallGraph->forksitesBegin(),
522  eit = tdCallGraph->forksitesEnd(); it != eit; ++it)
523  {
524  const SVFValue* forkedVal =tdCallGraph->getThreadAPI()->getForkedFun(*it)->getValue();
525  if(SVFUtil::dyn_cast<SVFFunction>(forkedVal) == nullptr)
526  {
527  SVFIR *pag = this->getPAG();
528  const NodeBS targets = this->getPts(pag->getValueNode(forkedVal)).toNodeBS();
529  for(NodeBS::iterator ii = targets.begin(), ie = targets.end(); ii != ie; ++ii)
530  {
531  if(ObjVar *objPN = SVFUtil::dyn_cast<ObjVar>(pag->getGNode(*ii)))
532  {
533  const MemObj *obj = pag->getObject(objPN);
534  if(obj->isFunction())
535  {
536  const SVFFunction *svfForkedFun = SVFUtil::cast<SVFFunction>(obj->getValue());
537  if(tdCallGraph->addIndirectForkEdge(*it, svfForkedFun))
538  newForkEdges[*it].insert(svfForkedFun);
539  }
540  }
541  }
542  }
543  }
544  }
545 }
const SVFValue * getValue() const
Get the reference value to this object.
bool isFunction() const
object attributes methods
PTACallGraph * callgraph
Call graph used for pointer analysis.
NodeBS toNodeBS() const
Returns this points-to set as a NodeBS.
Definition: PointsTo.cpp:313
iterator end() const
iterator begin() const

◆ readAndSetObjFieldSensitivity()

void BVDataPTAImpl::readAndSetObjFieldSensitivity ( std::ifstream &  f,
const std::string delimiterStr 
)
virtual

Definition at line 377 of file PointerAnalysisImpl.cpp.

378 {
379  string line;
380  // //update ObjVar status
381  while (F.good())
382  {
383  getline(F, line);
384  if (line.empty() || line == delimiterStr)
385  break;
386  // Parse a single line in the form of "baseNodeID insensitive"
387  istringstream ss(line);
388  NodeID base;
389  bool insensitive;
390  ss >> base >> insensitive;
391 
392  if (insensitive)
394  }
395 
396 }
#define F(f)
void setObjFieldInsensitive(NodeID id)

◆ readFromFile()

bool BVDataPTAImpl::readFromFile ( const std::string filename)
virtual

Load pointer analysis result form a file. It populates BVDataPTAImpl with the points-to data, and updates SVFIR with the SVFIR offset nodes created during Andersen's solving stage.

Definition at line 403 of file PointerAnalysisImpl.cpp.

404 {
405 
406  outs() << "Loading pointer analysis results from '" << filename << "'...";
407 
408  ifstream F(filename.c_str());
409  if (!F.is_open())
410  {
411  outs() << " error opening file for reading!\n";
412  return false;
413  }
414 
416 
418 
420 
422 
423  // Update callgraph
425 
426  F.close();
427  outs() << "\n";
428 
429  return true;
430 }
virtual void readAndSetObjFieldSensitivity(std::ifstream &f, const std::string &delimiterStr)
virtual bool updateCallGraph(const CallSiteToFunPtrMap &)
Update callgraph. This should be implemented by its subclass.
virtual void readPtsResultFromFile(std::ifstream &f)
virtual void readGepObjVarMapFromFile(std::ifstream &f)
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
Definition: SVFIR.h:350

◆ readGepObjVarMapFromFile()

void BVDataPTAImpl::readGepObjVarMapFromFile ( std::ifstream &  f)
virtual

Definition at line 341 of file PointerAnalysisImpl.cpp.

342 {
343  string line;
344  //read GepObjVarMap from file
345  SVFIR::NodeOffsetMap gepObjVarMap = pag->getGepObjNodeMap();
346  while (F.good())
347  {
348  getline(F, line);
349  if (line == "------") break;
350  // Parse a single line in the form of "ID baseNodeID offset"
351  istringstream ss(line);
352  NodeID base;
353  size_t offset;
354  NodeID id;
355  ss >> base >> offset >>id;
356  SVFIR::NodeOffsetMap::const_iterator iter = gepObjVarMap.find(std::make_pair(base, offset));
357  if (iter == gepObjVarMap.end())
358  {
359  SVFVar* node = pag->getGNode(base);
360  const MemObj* obj = nullptr;
361  if (GepObjVar* gepObjVar = SVFUtil::dyn_cast<GepObjVar>(node))
362  obj = gepObjVar->getMemObj();
363  else if (FIObjVar* baseNode = SVFUtil::dyn_cast<FIObjVar>(node))
364  obj = baseNode->getMemObj();
365  else if (DummyObjVar* baseNode = SVFUtil::dyn_cast<DummyObjVar>(node))
366  obj = baseNode->getMemObj();
367  else
368  assert(false && "new gep obj node kind?");
369  pag->addGepObjNode(obj, offset, id);
371  }
372 
373 
374  }
375 }
buffer offset
Definition: cJSON.cpp:1113
static NodeIDAllocator * get(void)
Return (singleton) allocator.
NodeID addGepObjNode(const MemObj *obj, const APOffset &apOffset, const NodeID gepId)
Add a field obj node, this method can only invoked by getGepObjVar.
Definition: SVFIR.cpp:449

◆ readPtsResultFromFile()

void BVDataPTAImpl::readPtsResultFromFile ( std::ifstream &  f)
virtual

Definition at line 287 of file PointerAnalysisImpl.cpp.

288 {
289  string line;
290  // Read analysis results from file
291  PTDataTy *ptD = getPTDataTy();
292 
293  // Read points-to sets
294  string delimiter1 = " -> { ";
295  string delimiter2 = " }";
296  map<NodeID, string> nodePtsMap;
297  map<string, PointsTo> strPtsMap;
298 
299  while (F.good())
300  {
301  // Parse a single line in the form of "var -> { obj1 obj2 obj3 }"
302  getline(F, line);
303  if (line.at(0) == '[' || line == "---VERSIONED---") continue;
304  if (line == "------") break;
305  size_t pos = line.find(delimiter1);
306  if (pos == string::npos) break;
307  if (line.back() != '}') break;
308 
309  // var
310  NodeID var = atoi(line.substr(0, pos).c_str());
311 
312  // objs
313  pos = pos + delimiter1.length();
314  size_t len = line.length() - pos - delimiter2.length();
315  string objs = line.substr(pos, len);
316  PointsTo dstPts;
317 
318  if (!objs.empty())
319  {
320  // map the variable ID to its unique string pointer set
321  nodePtsMap[var] = objs;
322  if (strPtsMap.count(objs)) continue;
323 
324  istringstream ss(objs);
325  NodeID obj;
326  while (ss.good())
327  {
328  ss >> obj;
329  dstPts.set(obj);
330  }
331  // map the string pointer set to the parsed PointsTo set
332  strPtsMap[objs] = dstPts;
333  }
334  }
335 
336  // map the variable ID to its pointer set
337  for (auto t: nodePtsMap)
338  ptD->unionPts(t.first, strPtsMap[t.second]);
339 }
PTData< NodeID, NodeSet, NodeID, PointsTo > PTDataTy
PTDataTy * getPTDataTy() const
Get points-to data structure.
void set(u32_t n)
Inserts n in the set.
Definition: PointsTo.cpp:157

◆ remapPointsToSets()

void BVDataPTAImpl::remapPointsToSets ( void  )

Remap all points-to sets to use the current mapping.

Definition at line 155 of file PointerAnalysisImpl.cpp.

156 {
158 }
virtual void remapAllPts(void)=0
Remaps all points-to sets to use the current mapping.

◆ unionPts() [1/2]

virtual bool SVF::BVDataPTAImpl::unionPts ( NodeID  id,
const PointsTo target 
)
inlinevirtual

Union/add points-to. Add the reverse points-to for node collapse purpose To be noted that adding reverse pts might incur 10% total overhead during solving

Reimplemented in SVF::Steensgaard, and SVF::Andersen.

Definition at line 113 of file PointerAnalysisImpl.h.

114  {
115  return ptD->unionPts(id, target);
116  }

◆ unionPts() [2/2]

virtual bool SVF::BVDataPTAImpl::unionPts ( NodeID  id,
NodeID  ptd 
)
inlinevirtual

Reimplemented in SVF::Steensgaard, and SVF::Andersen.

Definition at line 117 of file PointerAnalysisImpl.h.

118  {
119  return ptD->unionPts(id,ptd);
120  }

◆ updateCallGraph()

virtual bool SVF::BVDataPTAImpl::updateCallGraph ( const CallSiteToFunPtrMap )
inlineprotectedvirtual

Update callgraph. This should be implemented by its subclass.

Reimplemented in SVF::FlowSensitive, SVF::AndersenSCD, SVF::CFLAlias, and SVF::AndersenBase.

Definition at line 165 of file PointerAnalysisImpl.h.

166  {
167  assert(false && "Virtual function not implemented!");
168  return false;
169  }

◆ writeGepObjVarMapToFile()

void BVDataPTAImpl::writeGepObjVarMapToFile ( std::fstream &  f)
virtual

Definition at line 222 of file PointerAnalysisImpl.cpp.

223 {
224  //write gepObjVarMap to file(in form of: baseID offset gepObjNodeId)
225  SVFIR::NodeOffsetMap &gepObjVarMap = pag->getGepObjNodeMap();
226  for(SVFIR::NodeOffsetMap::const_iterator it = gepObjVarMap.begin(), eit = gepObjVarMap.end(); it != eit; it++)
227  {
228  const SVFIR::NodeOffset offsetPair = it -> first;
229  //write the base id to file
230  f << offsetPair.first << " ";
231  //write the offset to file
232  f << offsetPair.second << " ";
233  //write the gepObjNodeId to file
234  f << it->second << "\n";
235  }
236 
237 }
std::pair< NodeID, APOffset > NodeOffset
Definition: SVFIR.h:68

◆ writeObjVarToFile()

void BVDataPTAImpl::writeObjVarToFile ( const std::string filename)
virtual

Definition at line 160 of file PointerAnalysisImpl.cpp.

161 {
162  outs() << "Storing ObjVar to '" << filename << "'...";
163  error_code err;
164  std::fstream f(filename.c_str(), std::ios_base::out);
165  if (!f.good())
166  {
167  outs() << " error opening file for writing!\n";
168  return;
169  }
170 
171  // Write BaseNodes insensitivity to file
172  NodeBS NodeIDs;
173  for (auto it = pag->begin(), ie = pag->end(); it != ie; ++it)
174  {
175  PAGNode* pagNode = it->second;
176  if (!isa<ObjVar>(pagNode)) continue;
177  NodeID n = pag->getBaseObjVar(it->first);
178  if (NodeIDs.test(n)) continue;
179  f << n << " ";
180  f << isFieldInsensitive(n) << "\n";
181  NodeIDs.set(n);
182  }
183 
184  f << "------\n";
185 
186  f.close();
187  if (f.good())
188  {
189  outs() << "\n";
190  return;
191  }
192 
193 
194 }

◆ writePtsResultToFile()

void BVDataPTAImpl::writePtsResultToFile ( std::fstream &  f)
virtual

Definition at line 196 of file PointerAnalysisImpl.cpp.

197 {
198  // Write analysis results to file
199  for (auto it = pag->begin(), ie = pag->end(); it != ie; ++it)
200  {
201  NodeID var = it->first;
202  const PointsTo &pts = getPts(var);
203 
204  stringstream ss;
205  f << var << " -> { ";
206  if (pts.empty())
207  {
208  f << " ";
209  }
210  else
211  {
212  for (NodeID n: pts)
213  {
214  f << n << " ";
215  }
216  }
217  f << "}\n";
218  }
219 
220 }

◆ writeToFile()

void BVDataPTAImpl::writeToFile ( const std::string filename)
virtual

Interface for analysis result storage on filesystem.

Store pointer analysis result into a file. It includes the points-to relations, and all SVFIR nodes including those created when solving Andersen's constraints.

Definition at line 244 of file PointerAnalysisImpl.cpp.

245 {
246 
247  outs() << "Storing pointer analysis results to '" << filename << "'...";
248 
249  error_code err;
250  std::fstream f(filename.c_str(), std::ios_base::app);
251  if (!f.good())
252  {
253  outs() << " error opening file for writing!\n";
254  return;
255  }
256 
258 
259  f << "------\n";
260 
262 
263  f << "------\n";
264 
265  // Write BaseNodes insensitivity to file
266  NodeBS NodeIDs;
267  for (auto it = pag->begin(), ie = pag->end(); it != ie; ++it)
268  {
269  PAGNode* pagNode = it->second;
270  if (!isa<ObjVar>(pagNode)) continue;
271  NodeID n = pag->getBaseObjVar(it->first);
272  if (NodeIDs.test(n)) continue;
273  f << n << " ";
274  f << isFieldInsensitive(n) << "\n";
275  NodeIDs.set(n);
276  }
277 
278  // Job finish and close file
279  f.close();
280  if (f.good())
281  {
282  outs() << "\n";
283  return;
284  }
285 }
virtual void writeGepObjVarMapToFile(std::fstream &f)
virtual void writePtsResultToFile(std::fstream &f)

Member Data Documentation

◆ ptCache

PersistentPointsToCache<PointsTo> SVF::BVDataPTAImpl::ptCache
private

Definition at line 214 of file PointerAnalysisImpl.h.

◆ ptD

std::unique_ptr<PTDataTy> SVF::BVDataPTAImpl::ptD
private

Points-to data.

Definition at line 212 of file PointerAnalysisImpl.h.


The documentation for this class was generated from the following files: