Static Value-Flow Analysis
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
SVF::AndersenBase Class Referenceabstract

#include <Andersen.h>

Inheritance diagram for SVF::AndersenBase:
SVF::WPASolver< GraphType > SVF::BVDataPTAImpl SVF::PointerAnalysis SVF::Andersen SVF::Steensgaard SVF::TypeAnalysis SVF::AndersenSCD SVF::AndersenWaveDiff SVF::AndersenSFR

Public Types

typedef OrderedMap< const CallICFGNode *, NodeIDCallSite2DummyValPN
 
- Public Types inherited from SVF::WPASolver< GraphType >
typedef SVF::GenericGraphTraits< GraphType > GTraits
 Define the GTraits and node iterator for printing. More...
 
typedef GTraits::NodeRef GNODE
 
typedef GTraits::EdgeType GEDGE
 
typedef GTraits::ChildIteratorType child_iterator
 
typedef SCCDetection< GraphType > SCC
 
typedef FIFOWorkList< NodeIDWorkList
 
- Public Types inherited from SVF::BVDataPTAImpl
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

 AndersenBase (SVFIR *_pag, PTATY type=Andersen_BASE, bool alias_check=true)
 Constructor. More...
 
 ~AndersenBase () override
 Destructor. More...
 
virtual void analyze () override
 Andersen analysis. More...
 
virtual void solveAndwritePtsToFile (const std::string &filename)
 
virtual void readPtsFromFile (const std::string &filename)
 
virtual void solveConstraints ()
 
virtual void initialize () override
 Initialize analysis. More...
 
virtual void finalize () override
 Finalize analysis. More...
 
virtual bool updateCallGraph (const CallSiteToFunPtrMap &) override
 Update call graph. More...
 
virtual bool updateThreadCallGraph (const CallSiteToFunPtrMap &, NodePairSet &)
 Update thread call graph. More...
 
virtual void connectCaller2ForkedFunParams (const CallICFGNode *cs, const SVFFunction *F, NodePairSet &cpySrcNodes)
 Connect formal and actual parameters for indirect forksites. More...
 
virtual void connectCaller2CalleeParams (const CallICFGNode *cs, const SVFFunction *F, NodePairSet &cpySrcNodes)
 Connect formal and actual parameters for indirect callsites. More...
 
ConstraintGraphgetConstraintGraph ()
 Get constraint graph. More...
 
NodeID sccRepNode (NodeID id) const override
 SCC methods. More...
 
NodeBSsccSubNodes (NodeID repId)
 
virtual bool addCopyEdge (NodeID src, NodeID dst)=0
 Add copy edge on constraint graph. More...
 
void printStat ()
 dump statistics More...
 
virtual void normalizePointsTo () override
 
void cleanConsCG (NodeID id)
 remove redundant gepnodes in constraint graph More...
 
- Public Member Functions inherited from SVF::BVDataPTAImpl
 BVDataPTAImpl (SVFIR *pag, PointerAnalysis::PTATY type, bool alias_check=true)
 Constructor. More...
 
 ~BVDataPTAImpl () override=default
 Destructor. More...
 
PersistentPointsToCache< PointsTo > & getPtCache ()
 
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
 
- 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 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 AndersenBase *)
 Methods for support type inquiry through isa, cast, and dyn_cast: More...
 
static bool classof (const PointerAnalysis *pta)
 
- Static Public Member Functions inherited from SVF::BVDataPTAImpl
static bool classof (const PointerAnalysis *pta)
 

Public Attributes

NodeBS redundantGepNodes
 
- Public Attributes inherited from SVF::WPASolver< GraphType >
u32_t numOfIteration
 num of iterations during constraint solving More...
 

Static Public Attributes

static u32_t numOfProcessedAddr = 0
 Statistics. More...
 
static u32_t numOfProcessedCopy = 0
 Number of processed Addr edge. More...
 
static u32_t numOfProcessedGep = 0
 Number of processed Copy edge. More...
 
static u32_t numOfProcessedLoad = 0
 Number of processed Gep edge. More...
 
static u32_t numOfProcessedStore = 0
 Number of processed Load edge. More...
 
static u32_t numOfSfrs = 0
 Number of processed Store edge. More...
 
static u32_t numOfFieldExpand = 0
 
static u32_t numOfSCCDetection = 0
 
static double timeOfSCCDetection = 0
 
static double timeOfSCCMerges = 0
 
static double timeOfCollapse = 0
 
static u32_t AveragePointsToSetSize = 0
 
static u32_t MaxPointsToSetSize = 0
 
static double timeOfProcessCopyGep = 0
 
static double timeOfProcessLoadStore = 0
 
static double timeOfUpdateCallGraph = 0
 
- 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

void heapAllocatorViaIndCall (const CallICFGNode *cs, NodePairSet &cpySrcNodes)
 
- Protected Member Functions inherited from SVF::WPASolver< GraphType >
 WPASolver ()
 Constructor. More...
 
virtual ~WPASolver ()=default
 Destructor. More...
 
SCCgetSCCDetector () const
 Get SCC detector. More...
 
const GraphType graph ()
 Get/Set graph methods. More...
 
void setGraph (GraphType g)
 
virtual NodeStackSCCDetect ()
 SCC detection. More...
 
virtual NodeStackSCCDetect (NodeSet &candidates)
 
virtual void initWorklist ()
 
virtual void solveWorklist ()
 
virtual void processNode (NodeID)
 Following methods are to be implemented in child class, in order to achieve a fully worked PTA. More...
 
virtual void collapseFields ()
 collapse positive weight cycles of a graph More...
 
virtual void propagate (GNODE *v)
 
virtual bool propFromSrcToDst (GEDGE *)
 Propagate information from source to destination node, to be implemented in the child class. More...
 
NodeID popFromWorklist ()
 Worklist operations. More...
 
virtual void pushIntoWorklist (NodeID id)
 
bool isWorklistEmpty ()
 
bool isInWorklist (NodeID id)
 
GNODENode (NodeID id)
 Get node on the graph. More...
 
NodeID Node_Index (GNODE node)
 Get node ID. More...
 
- Protected Member Functions inherited from SVF::BVDataPTAImpl
PTDataTygetPTDataTy () const
 Get points-to data structure. 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...
 
- 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

ConstraintGraphconsCG
 Constraint Graph. More...
 
CallSite2DummyValPN callsite2DummyValPN
 
- Protected Attributes inherited from SVF::WPASolver< GraphType >
bool reanalyze
 Reanalyze if any constraint value changed. More...
 
u32_t iterationForPrintStat
 print out statistics for i-th iteration More...
 
GraphType _graph
 Graph. More...
 
std::unique_ptr< SCCscc
 SCC. More...
 
WorkList worklist
 Worklist for resolution. 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...
 

Additional Inherited Members

- Static Protected Attributes inherited from SVF::PointerAnalysis
static SVFIRpag = nullptr
 SVFIR. More...
 

Detailed Description

Definition at line 57 of file Andersen.h.

Member Typedef Documentation

◆ CallSite2DummyValPN

Definition at line 60 of file Andersen.h.

Constructor & Destructor Documentation

◆ AndersenBase()

SVF::AndersenBase::AndersenBase ( SVFIR _pag,
PTATY  type = Andersen_BASE,
bool  alias_check = true 
)
inline

Constructor.

Definition at line 65 of file Andersen.h.

66  : BVDataPTAImpl(_pag, type, alias_check), consCG(nullptr)
67  {
69  }
newitem type
Definition: cJSON.cpp:2739
ConstraintGraph * consCG
Constraint Graph.
Definition: Andersen.h:178
BVDataPTAImpl(SVFIR *pag, PointerAnalysis::PTATY type, bool alias_check=true)
Constructor.
u32_t OnTheFlyIterBudgetForStat
Flag for iteration budget for on-the-fly statistics.
u32_t iterationForPrintStat
print out statistics for i-th iteration
Definition: WPASolver.h:173

◆ ~AndersenBase()

AndersenBase::~AndersenBase ( )
override

Destructor.

Destructor

Definition at line 64 of file Andersen.cpp.

65 {
66  delete consCG;
67  consCG = nullptr;
68 }

Member Function Documentation

◆ addCopyEdge()

virtual bool SVF::AndersenBase::addCopyEdge ( NodeID  src,
NodeID  dst 
)
pure virtual

Add copy edge on constraint graph.

Implemented in SVF::TypeAnalysis, SVF::Steensgaard, SVF::AndersenSCD, and SVF::Andersen.

◆ analyze()

void AndersenBase::analyze ( )
overridevirtual

Andersen analysis.

Andersen analysis

Implements SVF::PointerAnalysis.

Reimplemented in SVF::TypeAnalysis.

Definition at line 133 of file Andersen.cpp.

134 {
135  if(!Options::ReadAnder().empty())
136  {
138  }
139  else
140  {
141  if(Options::WriteAnder().empty())
142  {
143  initialize();
145  finalize();
146  }
147  else
148  {
150  }
151  }
152 }
virtual void finalize() override
Finalize analysis.
Definition: Andersen.cpp:89
virtual void readPtsFromFile(const std::string &filename)
Definition: Andersen.cpp:157
virtual void initialize() override
Initialize analysis.
Definition: Andersen.cpp:73
virtual void solveConstraints()
Definition: Andersen.cpp:100
virtual void solveAndwritePtsToFile(const std::string &filename)
Definition: Andersen.cpp:168
static const Option< std::string > ReadAnder
Definition: Options.h:214
static const Option< std::string > WriteAnder
Definition: Options.h:212

◆ classof() [1/2]

static bool SVF::AndersenBase::classof ( const AndersenBase )
inlinestatic

Methods for support type inquiry through isa, cast, and dyn_cast:

Definition at line 105 of file Andersen.h.

106  {
107  return true;
108  }

◆ classof() [2/2]

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

Definition at line 109 of file Andersen.h.

110  {
111  return ( pta->getAnalysisTy() == Andersen_BASE
112  || pta->getAnalysisTy() == Andersen_WPA
113  || pta->getAnalysisTy() == AndersenWaveDiff_WPA
114  || pta->getAnalysisTy() == AndersenSCD_WPA
115  || pta->getAnalysisTy() == AndersenSFR_WPA
116  || pta->getAnalysisTy() == TypeCPP_WPA
117  || pta->getAnalysisTy() == Steensgaard_WPA);
118  }
@ AndersenSCD_WPA
Selective cycle detection andersen-style WPA.
@ Andersen_BASE
Base Andersen PTA.
@ Andersen_WPA
Andersen PTA.
@ 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.

◆ cleanConsCG()

void AndersenBase::cleanConsCG ( NodeID  id)

remove redundant gepnodes in constraint graph

Definition at line 180 of file Andersen.cpp.

181 {
182  consCG->resetSubs(consCG->getRep(id));
183  for (NodeID sub: consCG->getSubs(id))
184  consCG->resetRep(sub);
185  consCG->resetSubs(id);
186  consCG->resetRep(id);
187  assert(!consCG->hasGNode(id) && "this is either a rep nodeid or a sub nodeid should have already been merged to its field-insensitive base! ");
188 }
void resetSubs(NodeID node)
Definition: ConsG.h:256
void resetRep(NodeID node)
Definition: ConsG.h:268
NodeID getRep(NodeID node)
Definition: ConsG.h:264
NodeBS & getSubs(NodeID node)
Definition: ConsG.h:260
bool hasGNode(NodeID id) const
Has a node.
Definition: GenericGraph.h:661
u32_t NodeID
Definition: GeneralType.h:55

◆ connectCaller2CalleeParams()

virtual void SVF::AndersenBase::connectCaller2CalleeParams ( const CallICFGNode cs,
const SVFFunction F,
NodePairSet cpySrcNodes 
)
virtual

Connect formal and actual parameters for indirect callsites.

◆ connectCaller2ForkedFunParams()

void AndersenBase::connectCaller2ForkedFunParams ( const CallICFGNode cs,
const SVFFunction F,
NodePairSet cpySrcNodes 
)
virtual

Connect formal and actual parameters for indirect forksites.

Connect formal and actual parameters for indirect forksites

Definition at line 244 of file Andersen.cpp.

246 {
247  assert(F);
248 
249  DBOUT(DAndersen, outs() << "connect parameters from indirect forksite "
250  << cs->valueOnlyToString() << " to forked function "
251  << *F << "\n");
252 
253  ThreadCallGraph *tdCallGraph = SVFUtil::dyn_cast<ThreadCallGraph>(callgraph);
254 
255  const PAGNode *cs_arg = tdCallGraph->getThreadAPI()->getActualParmAtForkSite(cs);
256  const PAGNode *fun_arg = tdCallGraph->getThreadAPI()->getFormalParmOfForkedFun(F);
257 
258  if(cs_arg->isPointer() && fun_arg->isPointer())
259  {
260  DBOUT(DAndersen, outs() << "process actual parm"
261  << cs_arg->toString() << "\n");
262  NodeID srcAA = sccRepNode(cs_arg->getId());
263  NodeID dstFA = sccRepNode(fun_arg->getId());
264  if (addCopyEdge(srcAA, dstFA))
265  {
266  cpySrcNodes.insert(std::make_pair(srcAA, dstFA));
267  }
268  }
269 }
#define F(f)
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition: SVFType.h:484
#define DAndersen
Definition: SVFType.h:503
virtual bool addCopyEdge(NodeID src, NodeID dst)=0
Add copy edge on constraint graph.
NodeID sccRepNode(NodeID id) const override
SCC methods.
Definition: Andersen.h:129
PTACallGraph * callgraph
Call graph used for pointer analysis.
NodeID getId() const
Get ID.
Definition: GenericGraph.h:260
const std::string valueOnlyToString() const
Definition: LLVMUtil.cpp:688
virtual bool isPointer() const
Whether it is a pointer.
Definition: SVFVariables.h:106
virtual const std::string toString() const
const SVFVar * getFormalParmOfForkedFun(const SVFFunction *F) const
Return the formal parm of forked function (the first arg in pthread)
Definition: ThreadAPI.cpp:184
const SVFVar * getActualParmAtForkSite(const CallICFGNode *inst) const
Definition: ThreadAPI.cpp:178
ThreadAPI * getThreadAPI() const
Thread API.
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50

◆ finalize()

void AndersenBase::finalize ( )
overridevirtual

Finalize analysis.

Finalize analysis

dump constraint graph if PAGDotGraph flag is enabled

Reimplemented from SVF::BVDataPTAImpl.

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

Definition at line 89 of file Andersen.cpp.

90 {
93  consCG->dump("consCG_final");
94 
96  consCG->print();
98 }
void finalize() override
Finalization of pointer analysis, and normalize points-to information to Bit Vector representation.
void print()
Print CG into terminal.
Definition: ConsG.cpp:599
void dump(std::string name)
Dump graph into dot file.
Definition: ConsG.cpp:591
static const Option< bool > PrintCGGraph
Definition: Options.h:210
static const Option< bool > ConsCGDotGraph
Definition: Options.h:208

◆ getConstraintGraph()

ConstraintGraph* SVF::AndersenBase::getConstraintGraph ( )
inline

Get constraint graph.

Definition at line 122 of file Andersen.h.

123  {
124  return consCG;
125  }

◆ heapAllocatorViaIndCall()

void SVF::AndersenBase::heapAllocatorViaIndCall ( const CallICFGNode cs,
NodePairSet cpySrcNodes 
)
protected

◆ initialize()

void AndersenBase::initialize ( )
overridevirtual

Initialize analysis.

Initialize analysis

Build SVFIR

Create statistic class

Build Constraint Graph

Reimplemented from SVF::PointerAnalysis.

Reimplemented in SVF::TypeAnalysis, SVF::AndersenSFR, SVF::AndersenWaveDiff, and SVF::Andersen.

Definition at line 73 of file Andersen.cpp.

74 {
78  stat = new AndersenStat(this);
80  consCG = new ConstraintGraph(pag);
83  consCG->dump("consCG_initial");
84 }
virtual void initialize()
Initialization of a pointer analysis, including building symbol table and SVFIR etc.
PTAStat * stat
Statistics.
static SVFIR * pag
SVFIR.
void setGraph(GraphType g)
Definition: WPASolver.h:78

◆ normalizePointsTo()

virtual void SVF::AndersenBase::normalizePointsTo ( )
overridevirtual

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 from SVF::BVDataPTAImpl.

◆ printStat()

void SVF::AndersenBase::printStat ( )
inline

dump statistics

Definition at line 143 of file Andersen.h.

144  {
146  }
void dumpStat()
Dump the statistics.

◆ readPtsFromFile()

void AndersenBase::readPtsFromFile ( const std::string filename)
virtual

Andersen analysis: read pointer analysis result from file

Definition at line 157 of file Andersen.cpp.

158 {
159  initialize();
160  if (!filename.empty())
161  this->readFromFile(filename);
162  finalize();
163 }
virtual bool readFromFile(const std::string &filename)

◆ sccRepNode()

NodeID SVF::AndersenBase::sccRepNode ( NodeID  id) const
inlineoverridevirtual

SCC methods.

Reimplemented from SVF::WPASolver< GraphType >.

Reimplemented in SVF::Steensgaard.

Definition at line 129 of file Andersen.h.

130  {
131  return consCG->sccRepNode(id);
132  }
NodeID sccRepNode(NodeID id) const
SCC rep/sub nodes methods.
Definition: ConsG.h:235

◆ sccSubNodes()

NodeBS& SVF::AndersenBase::sccSubNodes ( NodeID  repId)
inline

Definition at line 133 of file Andersen.h.

134  {
135  return consCG->sccSubNodes(repId);
136  }
NodeBS & sccSubNodes(NodeID id)
Definition: ConsG.h:243

◆ solveAndwritePtsToFile()

void AndersenBase::solveAndwritePtsToFile ( const std::string filename)
virtual

Andersen analysis: solve constraints and write pointer analysis result to file

Initialization for the Solver

Definition at line 168 of file Andersen.cpp.

169 {
171  initialize();
172  if (!filename.empty())
173  this->writeObjVarToFile(filename);
175  if (!filename.empty())
176  this->writeToFile(filename);
177  finalize();
178 }
virtual void writeToFile(const std::string &filename)
Interface for analysis result storage on filesystem.
virtual void writeObjVarToFile(const std::string &filename)

◆ solveConstraints()

void AndersenBase::solveConstraints ( )
virtual

Definition at line 100 of file Andersen.cpp.

101 {
102  // Start solving constraints
103  DBOUT(DGENERAL, outs() << SVFUtil::pasMsg("Start Solving Constraints\n"));
104 
106 
107  initWorklist();
108  do
109  {
110  numOfIteration++;
112  printStat();
113 
114  reanalyze = false;
115 
116  solveWorklist();
117 
119  reanalyze = true;
120 
121  }
122  while (reanalyze);
123 
124  // Analysis is finished, reset the alarm if we set it.
125  SVFUtil::stopAnalysisLimitTimer(limitTimerSet);
126 
127  DBOUT(DGENERAL, outs() << SVFUtil::pasMsg("Finish Solving Constraints\n"));
128 }
#define DGENERAL
Definition: SVFType.h:490
virtual bool updateCallGraph(const CallSiteToFunPtrMap &) override
Update call graph.
Definition: Andersen.cpp:190
void printStat()
dump statistics
Definition: Andersen.h:143
static const Option< u32_t > AnderTimeLimit
Time limit for the Andersen's analyses.
Definition: Options.h:75
const CallSiteToFunPtrMap & getIndirectCallsites() const
Return all indirect callsites.
virtual void initWorklist()
Definition: WPASolver.h:97
u32_t numOfIteration
num of iterations during constraint solving
Definition: WPASolver.h:200
bool reanalyze
Reanalyze if any constraint value changed.
Definition: WPASolver.h:171
virtual void solveWorklist()
Definition: WPASolver.h:108
void stopAnalysisLimitTimer(bool limitTimerSet)
Definition: SVFUtil.cpp:310
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
Definition: SVFUtil.cpp:99
bool startAnalysisLimitTimer(unsigned timeLimit)
Definition: SVFUtil.cpp:289

◆ updateCallGraph()

bool AndersenBase::updateCallGraph ( const CallSiteToFunPtrMap callsites)
overridevirtual

Update call graph.

nodes as a src of a generated new copy edge

Reimplemented from SVF::BVDataPTAImpl.

Reimplemented in SVF::AndersenSCD.

Definition at line 190 of file Andersen.cpp.

191 {
192 
193  double cgUpdateStart = stat->getClk();
194 
195  CallEdgeMap newEdges;
196  onTheFlyCallGraphSolve(callsites, newEdges);
197  NodePairSet cpySrcNodes;
198  for (CallEdgeMap::iterator it = newEdges.begin(), eit = newEdges.end();
199  it != eit; ++it)
200  {
201  for (FunctionSet::iterator cit = it->second.begin(),
202  ecit = it->second.end();
203  cit != ecit; ++cit)
204  {
205  connectCaller2CalleeParams(it->first, *cit, cpySrcNodes);
206  }
207  }
208 
209  bool hasNewForkEdges = updateThreadCallGraph(callsites, cpySrcNodes);
210 
211  for (NodePairSet::iterator it = cpySrcNodes.begin(),
212  eit = cpySrcNodes.end();
213  it != eit; ++it)
214  {
215  pushIntoWorklist(it->first);
216  }
217 
218  double cgUpdateEnd = stat->getClk();
219  timeOfUpdateCallGraph += (cgUpdateEnd - cgUpdateStart) / TIMEINTERVAL;
220 
221  return ((!newEdges.empty()) || hasNewForkEdges);
222 }
#define TIMEINTERVAL
Definition: SVFType.h:512
static double timeOfUpdateCallGraph
Definition: Andersen.h:173
virtual void connectCaller2CalleeParams(const CallICFGNode *cs, const SVFFunction *F, NodePairSet &cpySrcNodes)
Connect formal and actual parameters for indirect callsites.
virtual bool updateThreadCallGraph(const CallSiteToFunPtrMap &, NodePairSet &)
Update thread call graph.
Definition: Andersen.cpp:224
virtual void onTheFlyCallGraphSolve(const CallSiteToFunPtrMap &callsites, CallEdgeMap &newEdges)
On the fly call graph construction.
OrderedMap< const CallICFGNode *, FunctionSet > CallEdgeMap
static double getClk(bool mark=false)
Definition: SVFStat.cpp:47
virtual void pushIntoWorklist(NodeID id)
Definition: WPASolver.h:156
Set< NodePair > NodePairSet
Definition: GeneralType.h:114

◆ updateThreadCallGraph()

bool AndersenBase::updateThreadCallGraph ( const CallSiteToFunPtrMap callsites,
NodePairSet cpySrcNodes 
)
virtual

Update thread call graph.

Definition at line 224 of file Andersen.cpp.

226 {
227  CallEdgeMap newForkEdges;
228  onTheFlyThreadCallGraphSolve(callsites, newForkEdges);
229  for (CallEdgeMap::iterator it = newForkEdges.begin(), eit = newForkEdges.end(); it != eit; it++)
230  {
231  for (FunctionSet::iterator cit = it->second.begin(),
232  ecit = it->second.end();
233  cit != ecit; ++cit)
234  {
235  connectCaller2ForkedFunParams(it->first, *cit, cpySrcNodes);
236  }
237  }
238  return !newForkEdges.empty();
239 }
virtual void connectCaller2ForkedFunParams(const CallICFGNode *cs, const SVFFunction *F, NodePairSet &cpySrcNodes)
Connect formal and actual parameters for indirect forksites.
Definition: Andersen.cpp:244
virtual void onTheFlyThreadCallGraphSolve(const CallSiteToFunPtrMap &callsites, CallEdgeMap &newForkEdges)
On the fly thread call graph construction respecting forksite.

Member Data Documentation

◆ AveragePointsToSetSize

u32_t AndersenBase::AveragePointsToSetSize = 0
static

Definition at line 169 of file Andersen.h.

◆ callsite2DummyValPN

CallSite2DummyValPN SVF::AndersenBase::callsite2DummyValPN
protected

Map an instruction to a dummy obj which created at an indirect callsite, which invokes a heap allocator

Definition at line 180 of file Andersen.h.

◆ consCG

ConstraintGraph* SVF::AndersenBase::consCG
protected

Constraint Graph.

Definition at line 178 of file Andersen.h.

◆ MaxPointsToSetSize

u32_t AndersenBase::MaxPointsToSetSize = 0
static

Definition at line 170 of file Andersen.h.

◆ numOfFieldExpand

u32_t AndersenBase::numOfFieldExpand = 0
static

Definition at line 163 of file Andersen.h.

◆ numOfProcessedAddr

u32_t AndersenBase::numOfProcessedAddr = 0
static

Statistics.

Definition at line 157 of file Andersen.h.

◆ numOfProcessedCopy

u32_t AndersenBase::numOfProcessedCopy = 0
static

Number of processed Addr edge.

Definition at line 158 of file Andersen.h.

◆ numOfProcessedGep

u32_t AndersenBase::numOfProcessedGep = 0
static

Number of processed Copy edge.

Definition at line 159 of file Andersen.h.

◆ numOfProcessedLoad

u32_t AndersenBase::numOfProcessedLoad = 0
static

Number of processed Gep edge.

Definition at line 160 of file Andersen.h.

◆ numOfProcessedStore

u32_t AndersenBase::numOfProcessedStore = 0
static

Number of processed Load edge.

Definition at line 161 of file Andersen.h.

◆ numOfSCCDetection

u32_t AndersenBase::numOfSCCDetection = 0
static

Definition at line 165 of file Andersen.h.

◆ numOfSfrs

u32_t AndersenBase::numOfSfrs = 0
static

Number of processed Store edge.

Definition at line 162 of file Andersen.h.

◆ redundantGepNodes

NodeBS SVF::AndersenBase::redundantGepNodes

Definition at line 153 of file Andersen.h.

◆ timeOfCollapse

double AndersenBase::timeOfCollapse = 0
static

Definition at line 168 of file Andersen.h.

◆ timeOfProcessCopyGep

double AndersenBase::timeOfProcessCopyGep = 0
static

Definition at line 171 of file Andersen.h.

◆ timeOfProcessLoadStore

double AndersenBase::timeOfProcessLoadStore = 0
static

Definition at line 172 of file Andersen.h.

◆ timeOfSCCDetection

double AndersenBase::timeOfSCCDetection = 0
static

Definition at line 166 of file Andersen.h.

◆ timeOfSCCMerges

double AndersenBase::timeOfSCCMerges = 0
static

Definition at line 167 of file Andersen.h.

◆ timeOfUpdateCallGraph

double AndersenBase::timeOfUpdateCallGraph = 0
static

Definition at line 173 of file Andersen.h.


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