Static Value-Flow Analysis
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
SVF::FlowSensitive Class Reference

#include <FlowSensitive.h>

Inheritance diagram for SVF::FlowSensitive:
SVF::WPAFSSolver< GraphType > SVF::BVDataPTAImpl SVF::WPASolver< GraphType > SVF::PointerAnalysis SVF::VersionedFlowSensitive

Public Types

typedef BVDataPTAImpl::MutDFPTDataTy MutDFPTDataTy
 
typedef BVDataPTAImpl::MutDFPTDataTy::DFPtsMap DFInOutMap
 
typedef BVDataPTAImpl::MutDFPTDataTy::PtsMap PtsMap
 
- 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

 FlowSensitive (SVFIR *_pag, PTATY type=FSSPARSE_WPA)
 Constructor. More...
 
 ~FlowSensitive () override=default
 Destructor. More...
 
virtual bool runOnModule (SVFModule *)
 We start from here. More...
 
void analyze () override
 Flow sensitive analysis. More...
 
virtual void solveAndwritePtsToFile (const std::string &filename)
 
virtual void readPtsFromFile (const std::string &filename)
 
virtual void solveConstraints ()
 
void initialize () override
 Initialize analysis. More...
 
void finalize () override
 Finalize analysis. More...
 
const std::string PTAName () const override
 Get PTA name. More...
 
SVFGgetSVFG () const
 Return SVFG. More...
 
- Public Member Functions inherited from SVF::WPAFSSolver< GraphType >
 WPAFSSolver ()
 Constructor. More...
 
virtual ~WPAFSSolver ()
 Destructor. More...
 
virtual NodeID sccRepNode (NodeID id) const
 SCC methods. 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...
 
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 FlowSensitivecreateFSWPA (SVFIR *_pag)
 Create single instance of flow-sensitive pointer analysis. More...
 
static void releaseFSWPA ()
 Release flow-sensitive pointer analysis. More...
 
static bool classof (const FlowSensitive *)
 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)
 

Protected Types

typedef SVFG::SVFGEdgeSetTy SVFGEdgeSetTy
 

Protected Member Functions

NodeStackSCCDetect () override
 SCC detection. More...
 
bool propFromSrcToDst (SVFGEdge *edge) override
 Propagation. More...
 
virtual bool propAlongDirectEdge (const DirectSVFGEdge *edge)
 Propagate points-to information along a DIRECT SVFG edge. More...
 
virtual bool propAlongIndirectEdge (const IndirectSVFGEdge *edge)
 Propagate points-to information along an INDIRECT SVFG edge. More...
 
virtual bool propVarPtsFromSrcToDst (NodeID var, const SVFGNode *src, const SVFGNode *dst)
 Propagate points-to information of a certain variable from src to dst. More...
 
virtual bool propagateFromAPToFP (const ActualParmSVFGNode *ap, const SVFGNode *dst)
 
virtual bool propagateFromFRToAR (const FormalRetSVFGNode *fr, const SVFGNode *dst)
 
virtual bool weakUpdateOutFromIn (const SVFGNode *node)
 Handle weak updates. More...
 
virtual bool strongUpdateOutFromIn (const SVFGNode *node, NodeID singleton)
 Handle strong updates. More...
 
bool propVarPtsAfterCGUpdated (NodeID var, const SVFGNode *src, const SVFGNode *dst)
 
virtual bool propDFOutToIn (const SVFGNode *srcStmt, NodeID srcVar, const SVFGNode *dstStmt, NodeID dstVar)
 
virtual bool propDFInToIn (const SVFGNode *srcStmt, NodeID srcVar, const SVFGNode *dstStmt, NodeID dstVar)
 
bool updateOutFromIn (const SVFGNode *srcStmt, NodeID srcVar, const SVFGNode *dstStmt, NodeID dstVar)
 Update data-flow points-to data. More...
 
virtual bool updateInFromIn (const SVFGNode *srcStmt, NodeID srcVar, const SVFGNode *dstStmt, NodeID dstVar)
 
virtual bool updateInFromOut (const SVFGNode *srcStmt, NodeID srcVar, const SVFGNode *dstStmt, NodeID dstVar)
 
virtual bool unionPtsFromIn (const SVFGNode *stmt, NodeID srcVar, NodeID dstVar)
 
virtual bool unionPtsFromTop (const SVFGNode *stmt, NodeID srcVar, NodeID dstVar)
 
void clearAllDFOutVarFlag (const SVFGNode *stmt)
 
void processNode (NodeID nodeId) override
 Handle various constraints. More...
 
bool processSVFGNode (SVFGNode *node)
 
virtual bool processAddr (const AddrSVFGNode *addr)
 
virtual bool processCopy (const CopySVFGNode *copy)
 
virtual bool processPhi (const PHISVFGNode *phi)
 
virtual bool processGep (const GepSVFGNode *edge)
 
virtual bool processLoad (const LoadSVFGNode *load)
 
virtual bool processStore (const StoreSVFGNode *store)
 
bool updateCallGraph (const CallSiteToFunPtrMap &callsites) override
 Update call graph. More...
 
void connectCallerAndCallee (const CallEdgeMap &newEdges, SVFGEdgeSetTy &edges)
 Connect nodes in SVFG. More...
 
virtual void updateConnectedNodes (const SVFGEdgeSetTy &edges)
 Update nodes connected during updating call graph. More...
 
bool isStrongUpdate (const SVFGNode *node, NodeID &singleton)
 Return TRUE if this is a strong update STORE statement. More...
 
virtual void countAliases (Set< std::pair< NodeID, NodeID >> cmp, unsigned *mayAliases, unsigned *noAliases)
 Fills may/noAliases for the location/pointer pairs in cmp. More...
 
const PointsTogetDFInPtsSet (const SVFGNode *stmt, const NodeID node)
 Get points-to set for a node from data flow IN/OUT set at a statement. More...
 
const PointsTogetDFOutPtsSet (const SVFGNode *stmt, const NodeID node)
 
virtual void cluster (void)
 
virtual void plainMap (void) const
 Sets the global best mapping as a plain mapping, i.e. n -> n. More...
 
void svfgStat ()
 
const DFInOutMapgetDFInputMap () const
 
const DFInOutMapgetDFOutputMap () const
 
- 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 (NodeSet &candidates)
 
virtual void initWorklist ()
 
virtual void solveWorklist ()
 
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...
 
virtual void normalizePointsTo ()
 
- 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

SVFGsvfg
 
SVFGBuilder memSSA
 
AndersenWaveDiffander
 
std::vector< std::pair< hclust_fast_methods, std::vector< NodeID > > > candidateMappings
 Save candidate mappings for evaluation's sake. More...
 
u32_t numOfProcessedAddr
 Statistics. More...
 
u32_t numOfProcessedCopy
 Number of processed Addr node. More...
 
u32_t numOfProcessedGep
 Number of processed Copy node. More...
 
u32_t numOfProcessedPhi
 Number of processed Gep node. More...
 
u32_t numOfProcessedLoad
 Number of processed Phi node. More...
 
u32_t numOfProcessedStore
 Number of processed Load node. More...
 
u32_t numOfProcessedActualParam
 Number of processed Store node. More...
 
u32_t numOfProcessedFormalRet
 Number of processed actual param node. More...
 
u32_t numOfProcessedMSSANode
 Number of processed formal ret node. More...
 
u32_t maxSCCSize
 Number of processed mssa node. More...
 
u32_t numOfSCC
 
u32_t numOfNodesInSCC
 
double solveTime
 time of solve. More...
 
double sccTime
 time of SCC detection. More...
 
double processTime
 time of processNode. More...
 
double propagationTime
 time of points-to propagation. More...
 
double directPropaTime
 time of points-to propagation of address-taken objects More...
 
double indirectPropaTime
 time of points-to propagation of top-level pointers More...
 
double updateTime
 time of strong/weak updates. More...
 
double addrTime
 time of handling address edges More...
 
double copyTime
 time of handling copy edges More...
 
double gepTime
 time of handling gep edges More...
 
double loadTime
 time of load edges More...
 
double storeTime
 time of store edges More...
 
double phiTime
 time of phi nodes. More...
 
double updateCallGraphTime
 time of updating call graph More...
 
NodeBS svfgHasSU
 
- Protected Attributes inherited from SVF::WPAFSSolver< GraphType >
NodeStack nodeStack
 stack used for processing nodes. More...
 
- 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...
 

Static Protected Attributes

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

Friends

class FlowSensitiveStat
 

Additional Inherited Members

- Public Attributes inherited from SVF::WPASolver< GraphType >
u32_t numOfIteration
 num of iterations during constraint solving More...
 
- 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_"
 

Detailed Description

Definition at line 49 of file FlowSensitive.h.

Member Typedef Documentation

◆ DFInOutMap

Definition at line 57 of file FlowSensitive.h.

◆ MutDFPTDataTy

Definition at line 56 of file FlowSensitive.h.

◆ PtsMap

Definition at line 58 of file FlowSensitive.h.

◆ SVFGEdgeSetTy

Definition at line 53 of file FlowSensitive.h.

Constructor & Destructor Documentation

◆ FlowSensitive()

SVF::FlowSensitive::FlowSensitive ( SVFIR _pag,
PTATY  type = FSSPARSE_WPA 
)
inlineexplicit

Constructor.

Definition at line 61 of file FlowSensitive.h.

62  {
63  svfg = nullptr;
73  }
newitem type
Definition: cJSON.cpp:2739
BVDataPTAImpl(SVFIR *pag, PointerAnalysis::PTATY type, bool alias_check=true)
Constructor.
u32_t numOfProcessedLoad
Number of processed Phi node.
u32_t numOfProcessedCopy
Number of processed Addr node.
double gepTime
time of handling gep edges
double indirectPropaTime
time of points-to propagation of top-level pointers
double addrTime
time of handling address edges
double solveTime
time of solve.
u32_t numOfProcessedStore
Number of processed Load node.
double storeTime
time of store edges
double copyTime
time of handling copy edges
u32_t numOfProcessedGep
Number of processed Copy node.
u32_t maxSCCSize
Number of processed mssa node.
double loadTime
time of load edges
u32_t numOfProcessedActualParam
Number of processed Store node.
u32_t numOfProcessedPhi
Number of processed Gep node.
double propagationTime
time of points-to propagation.
u32_t numOfProcessedFormalRet
Number of processed actual param node.
double directPropaTime
time of points-to propagation of address-taken objects
double processTime
time of processNode.
u32_t numOfProcessedAddr
Statistics.
double phiTime
time of phi nodes.
double sccTime
time of SCC detection.
double updateTime
time of strong/weak updates.
u32_t numOfProcessedMSSANode
Number of processed formal ret node.
double updateCallGraphTime
time of updating call graph
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
WPAFSSolver< SVFG * > WPASVFGFSSolver
Definition: FlowSensitive.h:43

◆ ~FlowSensitive()

SVF::FlowSensitive::~FlowSensitive ( )
overridedefault

Destructor.

Member Function Documentation

◆ analyze()

void FlowSensitive::analyze ( )
overridevirtual

Flow sensitive analysis.

Start analysis

Implements SVF::PointerAnalysis.

Definition at line 128 of file FlowSensitive.cpp.

129 {
130  if(!Options::ReadAnder().empty())
131  {
133  }
134  else
135  {
136  if(Options::WriteAnder().empty())
137  {
138  initialize();
140  finalize();
141  }
142  else
143  {
145  }
146  }
147 }
virtual void solveConstraints()
virtual void readPtsFromFile(const std::string &filename)
void finalize() override
Finalize analysis.
void initialize() override
Initialize analysis.
virtual void solveAndwritePtsToFile(const std::string &filename)
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::FlowSensitive::classof ( const FlowSensitive )
inlinestatic

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

Definition at line 124 of file FlowSensitive.h.

125  {
126  return true;
127  }

◆ classof() [2/2]

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

Definition at line 128 of file FlowSensitive.h.

129  {
130  return pta->getAnalysisTy() == FSSPARSE_WPA;
131  }
@ FSSPARSE_WPA
Sparse flow sensitive WPA.

◆ clearAllDFOutVarFlag()

void SVF::FlowSensitive::clearAllDFOutVarFlag ( const SVFGNode stmt)
inlineprotected

Definition at line 211 of file FlowSensitive.h.

212  {
213  getDFPTDataTy()->clearAllDFOutUpdatedVar(stmt->getId());
214  }
DFPTDataTy * getDFPTDataTy() const
virtual void clearAllDFOutUpdatedVar(LocID)=0

◆ cluster()

void FlowSensitive::cluster ( void  )
protectedvirtual

Performs clustering based on ander, setting the global best mapping accordingly.

Reimplemented in SVF::VersionedFlowSensitive.

Definition at line 825 of file FlowSensitive.cpp.

826 {
827  std::vector<std::pair<unsigned, unsigned>> keys;
828  for (const auto& pair : *pag)
829  keys.emplace_back(pair.first, 1);
830 
831  PointsTo::MappingPtr nodeMapping =
832  std::make_shared<std::vector<NodeID>>(NodeIDAllocator::Clusterer::cluster(ander, keys, candidateMappings, "aux-ander"));
833  PointsTo::MappingPtr reverseNodeMapping =
834  std::make_shared<std::vector<NodeID>>(NodeIDAllocator::Clusterer::getReverseNodeMapping(*nodeMapping));
835 
836  PointsTo::setCurrentBestNodeMapping(nodeMapping, reverseNodeMapping);
837 }
AndersenWaveDiff * ander
std::vector< std::pair< hclust_fast_methods, std::vector< NodeID > > > candidateMappings
Save candidate mappings for evaluation's sake.
static std::vector< NodeID > cluster(BVDataPTAImpl *pta, const std::vector< std::pair< NodeID, unsigned >> keys, std::vector< std::pair< hclust_fast_methods, std::vector< NodeID >>> &candidates, std::string evalSubtitle="")
static std::vector< NodeID > getReverseNodeMapping(const std::vector< NodeID > &nodeMapping)
static SVFIR * pag
SVFIR.
std::shared_ptr< std::vector< NodeID > > MappingPtr
Definition: PointsTo.h:42
static void setCurrentBestNodeMapping(MappingPtr newCurrentBestNodeMapping, MappingPtr newCurrentBestReverseNodeMapping)
Definition: PointsTo.cpp:371

◆ connectCallerAndCallee()

void FlowSensitive::connectCallerAndCallee ( const CallEdgeMap newEdges,
SVFGEdgeSetTy edges 
)
protected

Connect nodes in SVFG.

Handle parameter passing in SVFG

Definition at line 740 of file FlowSensitive.cpp.

741 {
742  CallEdgeMap::const_iterator iter = newEdges.begin();
743  CallEdgeMap::const_iterator eiter = newEdges.end();
744  for (; iter != eiter; iter++)
745  {
746  const CallICFGNode* cs = iter->first;
747  const FunctionSet & functions = iter->second;
748  for (FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
749  {
750  const SVFFunction* func = *func_iter;
751  svfg->connectCallerAndCallee(cs, func, edges);
752  }
753  }
754 }
Set< const SVFFunction * > FunctionSet
virtual void connectCallerAndCallee(const CallICFGNode *cs, const SVFFunction *callee, SVFGEdgeSetTy &edges)
Connect SVFG nodes between caller and callee for indirect call site.
Definition: SVFG.cpp:658

◆ countAliases()

void FlowSensitive::countAliases ( Set< std::pair< NodeID, NodeID >>  cmp,
unsigned *  mayAliases,
unsigned *  noAliases 
)
protectedvirtual

Fills may/noAliases for the location/pointer pairs in cmp.

Definition at line 856 of file FlowSensitive.cpp.

857 {
858  for (std::pair<NodeID, NodeID> locPA : cmp)
859  {
860  // loc doesn't make a difference for FSPTA.
861  NodeID p = locPA.second;
862  for (std::pair<NodeID, NodeID> locPB : cmp)
863  {
864  if (locPB == locPA) continue;
865 
866  NodeID q = locPB.second;
867 
868  switch (alias(p, q))
869  {
871  ++(*noAliases);
872  break;
874  ++(*mayAliases);
875  break;
876  default:
877  assert("Not May/NoAlias?");
878  }
879  }
880  }
881 
882 }
cJSON * p
Definition: cJSON.cpp:2559
AliasResult alias(const SVFValue *V1, const SVFValue *V2) override
Interface expose to users of our pointer analysis, given Value infos.
u32_t NodeID
Definition: GeneralType.h:55
@ MayAlias
Definition: SVFType.h:529
@ NoAlias
Definition: SVFType.h:528

◆ createFSWPA()

static FlowSensitive* SVF::FlowSensitive::createFSWPA ( SVFIR _pag)
inlinestatic

Create single instance of flow-sensitive pointer analysis.

Definition at line 79 of file FlowSensitive.h.

80  {
81  if (fspta == nullptr)
82  {
83  fspta = std::unique_ptr<FlowSensitive>(new FlowSensitive(_pag));
84  fspta->analyze();
85  }
86  return fspta.get();
87  }
static std::unique_ptr< FlowSensitive > fspta
FlowSensitive(SVFIR *_pag, PTATY type=FSSPARSE_WPA)
Constructor.
Definition: FlowSensitive.h:61

◆ finalize()

void FlowSensitive::finalize ( )
overridevirtual

Finalize analysis.

Finalize analysis

Reimplemented from SVF::BVDataPTAImpl.

Reimplemented in SVF::VersionedFlowSensitive.

Definition at line 163 of file FlowSensitive.cpp.

164 {
165  if(Options::DumpVFG())
166  svfg->dump("fs_solved", true);
167 
169  while (nodeStack.empty() == false)
170  {
171  NodeID rep = nodeStack.top();
172  nodeStack.pop();
173  const NodeBS& subNodes = getSCCDetector()->subNodes(rep);
174  if (subNodes.count() > maxSCCSize)
175  maxSCCSize = subNodes.count();
176  if (subNodes.count() > 1)
177  {
178  numOfNodesInSCC += subNodes.count();
179  numOfSCC++;
180  }
181  }
182 
183  // TODO: check -stat too.
184  if (Options::ClusterFs())
185  {
187  const PTDataTy *ptd = getPTDataTy();
188  // TODO: should we use liveOnly?
189  Map<PointsTo, unsigned> allPts = ptd->getAllPts(true);
190  // TODO: parameterise final arg.
192  NodeIDAllocator::Clusterer::printStats("post-main: best", stats);
193 
194  // Do the same for the candidates. TODO: probably temporary for eval. purposes.
195  for (std::pair<hclust_fast_methods, std::vector<NodeID>> &candidate : candidateMappings)
196  {
197  // Can reuse stats, since we're always filling it with `evaluate`, it will always be overwritten.
198  NodeIDAllocator::Clusterer::evaluate(candidate.second, allPts, stats, true);
199  NodeIDAllocator::Clusterer::printStats("post-main: candidate " + SVFUtil::hclustMethodToString(candidate.first), stats);
200  }
201  }
202 
204 }
void finalize() override
Finalization of pointer analysis, and normalize points-to information to Bit Vector representation.
PTData< NodeID, NodeSet, NodeID, PointsTo > PTDataTy
PTDataTy * getPTDataTy() const
Get points-to data structure.
static void printStats(std::string title, Map< std::string, std::string > &stats)
static void evaluate(const std::vector< NodeID > &nodeMap, const Map< PointsTo, unsigned > pointsToSets, Map< std::string, std::string > &stats, bool accountForOcc)
Fills in *NumWords statistics in stats..
static const Option< bool > ClusterFs
Whether to cluster FS or VFS with the auxiliary Andersen's.
Definition: Options.h:44
static const Option< bool > DumpVFG
Definition: Options.h:111
static MappingPtr getCurrentBestNodeMapping()
Definition: PointsTo.cpp:361
const NodeBS & subNodes(NodeID n) const
get all subnodes in one scc, if size is empty insert itself into the set
Definition: SCC.h:173
void dump(const std::string &file, bool simple=false)
Dump graph into dot file.
Definition: SVFG.cpp:576
unsigned count() const
NodeStack nodeStack
stack used for processing nodes.
Definition: WPAFSSolver.h:64
SCC * getSCCDetector() const
Get SCC detector.
Definition: WPASolver.h:67
virtual NodeStack & SCCDetect()
SCC detection.
Definition: WPASolver.h:86
hclust_fast_methods
Definition: fastcluster.h:66
std::string hclustMethodToString(hclust_fast_methods method)
Returns a string representation of a hclust method.
Definition: SVFUtil.cpp:260
std::stack< NodeID > NodeStack
Definition: GeneralType.h:118
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
Definition: GeneralType.h:101

◆ getDFInPtsSet()

const PointsTo& SVF::FlowSensitive::getDFInPtsSet ( const SVFGNode stmt,
const NodeID  node 
)
inlineprotected

Get points-to set for a node from data flow IN/OUT set at a statement.

Definition at line 248 of file FlowSensitive.h.

249  {
250  return getDFPTDataTy()->getDFInPtsSet(stmt->getId(),node);
251  }
virtual const DataSet & getDFInPtsSet(LocID loc, const Key &var)=0

◆ getDFInputMap()

const DFInOutMap& SVF::FlowSensitive::getDFInputMap ( ) const
inlineprotected

Get IN/OUT data flow map. May only be called when the backing is MUTABLE.

Definition at line 261 of file FlowSensitive.h.

262  {
263  return getMutDFPTDataTy()->getDFIn();
264  }
MutDFPTDataTy * getMutDFPTDataTy() const
const DFPtsMap & getDFIn()

◆ getDFOutPtsSet()

const PointsTo& SVF::FlowSensitive::getDFOutPtsSet ( const SVFGNode stmt,
const NodeID  node 
)
inlineprotected

Definition at line 252 of file FlowSensitive.h.

253  {
254  return getDFPTDataTy()->getDFOutPtsSet(stmt->getId(),node);
255  }
virtual const DataSet & getDFOutPtsSet(LocID loc, const Key &var)=0

◆ getDFOutputMap()

const DFInOutMap& SVF::FlowSensitive::getDFOutputMap ( ) const
inlineprotected

Definition at line 265 of file FlowSensitive.h.

266  {
267  return getMutDFPTDataTy()->getDFOut();
268  }
const DFPtsMap & getDFOut()

◆ getSVFG()

SVFG* SVF::FlowSensitive::getSVFG ( ) const
inline

Return SVFG.

Definition at line 135 of file FlowSensitive.h.

136  {
137  return svfg;
138  }

◆ initialize()

void FlowSensitive::initialize ( )
overridevirtual

Initialize analysis.

Initialize analysis

Reimplemented from SVF::PointerAnalysis.

Reimplemented in SVF::VersionedFlowSensitive.

Definition at line 45 of file FlowSensitive.cpp.

46 {
48 
49  stat = new FlowSensitiveStat(this);
50 
51  // TODO: support clustered aux. Andersen's.
52  assert(!Options::ClusterAnder() && "FlowSensitive::initialize: clustering auxiliary Andersen's unsupported.");
54 
55  // If cluster option is not set, it will give us a no-mapping points-to set.
57  && "FS::init: plain-mapping and cluster-fs are mutually exclusive.");
58  if (Options::ClusterFs())
59  {
60  cluster();
61  // Reset the points-to cache although empty so the new mapping could
62  // be applied to the inserted empty set.
63  getPtCache().reset();
64  }
65  else if (Options::PlainMappingFs())
66  {
67  plainMap();
68  // As above.
69  getPtCache().reset();
70  }
71 
73 
74  setGraph(svfg);
75  //AndersenWaveDiff::releaseAndersenWaveDiff();
76 }
static AndersenWaveDiff * createAndersenWaveDiff(SVFIR *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
Definition: Andersen.h:408
PersistentPointsToCache< PointsTo > & getPtCache()
virtual void plainMap(void) const
Sets the global best mapping as a plain mapping, i.e. n -> n.
SVFGBuilder memSSA
friend class FlowSensitiveStat
Definition: FlowSensitive.h:51
virtual void cluster(void)
static const Option< bool > PlainMappingFs
Use an explicitly plain mapping with flow-sensitive (not null).
Definition: Options.h:47
static const Option< bool > ClusterAnder
Whether to stage Andersen's with Steensgaard and cluster based on that data.
Definition: Options.h:41
SVFIR * getPAG() const
virtual void initialize()
Initialization of a pointer analysis, including building symbol table and SVFIR etc.
PTAStat * stat
Statistics.
SVFG * buildPTROnlySVFG(BVDataPTAImpl *pta)
Definition: SVFGBuilder.cpp:41
void setGraph(GraphType g)
Definition: WPASolver.h:78

◆ isStrongUpdate()

bool FlowSensitive::isStrongUpdate ( const SVFGNode node,
NodeID singleton 
)
protected

Return TRUE if this is a strong update STORE statement.

Return TRUE if this is a strong update STORE statement.

Find the unique element in cpts

Definition at line 660 of file FlowSensitive.cpp.

661 {
662  bool isSU = false;
663  if (const StoreSVFGNode* store = SVFUtil::dyn_cast<StoreSVFGNode>(node))
664  {
665  const PointsTo& dstCPSet = getPts(store->getPAGDstNodeID());
666  if (dstCPSet.count() == 1)
667  {
669  PointsTo::iterator it = dstCPSet.begin();
670  singleton = *it;
671 
672  // Strong update can be made if this points-to target is not heap, array or field-insensitive.
673  if (!isHeapMemObj(singleton) && !isArrayMemObj(singleton)
674  && pag->getBaseObj(singleton)->isFieldInsensitive() == false
675  && !isLocalVarInRecursiveFun(singleton))
676  {
677  isSU = true;
678  }
679  }
680  }
681  return isSU;
682 }
const PointsTo & getPts(NodeID id) override
bool isFieldInsensitive() const
Return true if its field limit is 0.
bool isLocalVarInRecursiveFun(NodeID id) const
Whether a local variable is in function recursions.
bool isArrayMemObj(NodeID id) const
bool isHeapMemObj(NodeID id) const
Whether this object is heap or array.
u32_t count() const
Returns number of elements.
Definition: PointsTo.cpp:111
const_iterator begin() const
Definition: PointsTo.h:128
const MemObj * getBaseObj(NodeID id) const
Definition: SVFIR.h:459

◆ plainMap()

void FlowSensitive::plainMap ( void  ) const
protectedvirtual

Sets the global best mapping as a plain mapping, i.e. n -> n.

Definition at line 839 of file FlowSensitive.cpp.

840 {
841  assert(Options::NodeAllocStrat() == NodeIDAllocator::Strategy::DENSE
842  && "FS::cluster: plain mapping requires dense allocation strategy.");
843 
844  const size_t numObjects = NodeIDAllocator::get()->getNumObjects();
845  PointsTo::MappingPtr plainMapping = std::make_shared<std::vector<NodeID>>(numObjects);
846  PointsTo::MappingPtr reversePlainMapping = std::make_shared<std::vector<NodeID>>(numObjects);
847  for (NodeID i = 0; i < plainMapping->size(); ++i)
848  {
849  plainMapping->at(i) = i;
850  reversePlainMapping->at(i) = i;
851  }
852 
853  PointsTo::setCurrentBestNodeMapping(plainMapping, reversePlainMapping);
854 }
static NodeIDAllocator * get(void)
Return (singleton) allocator.
NodeID getNumObjects(void) const
Returns the total number of memory objects.
static const OptionMap< SVF::NodeIDAllocator::Strategy > NodeAllocStrat
Definition: Options.h:35

◆ processAddr()

bool FlowSensitive::processAddr ( const AddrSVFGNode addr)
protectedvirtual

Process address node

TODO: If this object has been set as field-insensitive, just add the insensitive object node into dst pointer's pts.

Definition at line 450 of file FlowSensitive.cpp.

451 {
452  double start = stat->getClk();
453  NodeID srcID = addr->getPAGSrcNodeID();
456  if (isFieldInsensitive(srcID))
457  srcID = getFIObjVar(srcID);
458  bool changed = addPts(addr->getPAGDstNodeID(), srcID);
459  double end = stat->getClk();
460  addrTime += (end - start) / TIMEINTERVAL;
461  return changed;
462 }
#define TIMEINTERVAL
Definition: SVFType.h:512
virtual bool addPts(NodeID id, NodeID ptd)
bool isFieldInsensitive(NodeID id) const
NodeID getFIObjVar(NodeID id)
static double getClk(bool mark=false)
Definition: SVFStat.cpp:47
NodeID getPAGDstNodeID() const
Definition: VFGNode.h:157
NodeID getPAGSrcNodeID() const
Definition: VFGNode.h:152

◆ processCopy()

bool FlowSensitive::processCopy ( const CopySVFGNode copy)
protectedvirtual

Process copy node

Definition at line 467 of file FlowSensitive.cpp.

468 {
469  double start = stat->getClk();
470  bool changed = unionPts(copy->getPAGDstNodeID(), copy->getPAGSrcNodeID());
471  double end = stat->getClk();
472  copyTime += (end - start) / TIMEINTERVAL;
473  return changed;
474 }
copy
Definition: cJSON.cpp:414
virtual bool unionPts(NodeID id, const PointsTo &target)

◆ processGep()

bool FlowSensitive::processGep ( const GepSVFGNode edge)
protectedvirtual

Process gep node

Definition at line 500 of file FlowSensitive.cpp.

501 {
502  double start = stat->getClk();
503  bool changed = false;
504  const PointsTo& srcPts = getPts(edge->getPAGSrcNodeID());
505 
506  PointsTo tmpDstPts;
507  const GepStmt* gepStmt = SVFUtil::cast<GepStmt>(edge->getPAGEdge());
508  if (gepStmt->isVariantFieldGep())
509  {
510  for (NodeID o : srcPts)
511  {
512  if (isBlkObjOrConstantObj(o))
513  {
514  tmpDstPts.set(o);
515  continue;
516  }
517 
519  tmpDstPts.set(getFIObjVar(o));
520  }
521  }
522  else
523  {
524  for (NodeID o : srcPts)
525  {
527  {
528  tmpDstPts.set(o);
529  continue;
530  }
531 
532  NodeID fieldSrcPtdNode = getGepObjVar(o, gepStmt->getAccessPath().getConstantStructFldIdx());
533  tmpDstPts.set(fieldSrcPtdNode);
534  }
535  }
536 
537  if (unionPts(edge->getPAGDstNodeID(), tmpDstPts))
538  changed = true;
539 
540  double end = stat->getClk();
541  gepTime += (end - start) / TIMEINTERVAL;
542  return changed;
543 }
APOffset getConstantStructFldIdx() const
Get methods.
Definition: AccessPath.h:100
bool isVariantFieldGep() const
Gep statement with a variant field index (pointer arithmetic) for struct field access.
const AccessPath & getAccessPath() const
virtual bool isBlkObjOrConstantObj(NodeID ptd) const
NodeID getGepObjVar(NodeID id, const APOffset &ap)
void setObjFieldInsensitive(NodeID id)
void set(u32_t n)
Inserts n in the set.
Definition: PointsTo.cpp:157
const PAGEdge * getPAGEdge() const
Definition: VFGNode.h:147

◆ processLoad()

bool FlowSensitive::processLoad ( const LoadSVFGNode load)
protectedvirtual

Process load node

Foreach node \in src pts(dst) = union pts(node)

If the ptd is a field-insensitive node, we should also get all field nodes' points-to sets and pass them to pagDst.

Reimplemented in SVF::VersionedFlowSensitive.

Definition at line 552 of file FlowSensitive.cpp.

553 {
554  double start = stat->getClk();
555  bool changed = false;
556 
557  NodeID dstVar = load->getPAGDstNodeID();
558 
559  const PointsTo& srcPts = getPts(load->getPAGSrcNodeID());
560 
561  // p = *q, the type of p must be a pointer
562  if(load->getPAGDstNode()->isPointer())
563  {
564  for (PointsTo::iterator ptdIt = srcPts.begin(); ptdIt != srcPts.end(); ++ptdIt)
565  {
566  NodeID ptd = *ptdIt;
567 
568  if (pag->isConstantObj(ptd))
569  continue;
570 
571  if (unionPtsFromIn(load, ptd, dstVar))
572  changed = true;
573 
574  if (isFieldInsensitive(ptd))
575  {
578  const NodeBS& allFields = getAllFieldsObjVars(ptd);
579  for (NodeBS::iterator fieldIt = allFields.begin(), fieldEit = allFields.end();
580  fieldIt != fieldEit; ++fieldIt)
581  {
582  if (unionPtsFromIn(load, *fieldIt, dstVar))
583  changed = true;
584  }
585  }
586  }
587  }
588  double end = stat->getClk();
589  loadTime += (end - start) / TIMEINTERVAL;
590  return changed;
591 }
virtual bool unionPtsFromIn(const SVFGNode *stmt, NodeID srcVar, NodeID dstVar)
virtual const NodeBS & getAllFieldsObjVars(NodeID id)
const_iterator end() const
Definition: PointsTo.h:132
bool isConstantObj(NodeID id) const
Definition: SVFIR.h:443
virtual bool isPointer() const
Whether it is a pointer.
Definition: SVFVariables.h:106
iterator end() const
iterator begin() const
PAGNode * getPAGDstNode() const
Definition: VFGNode.h:167

◆ processNode()

void FlowSensitive::processNode ( NodeID  nodeId)
overrideprotectedvirtual

Handle various constraints.

Process each SVFG node

Reimplemented from SVF::WPASolver< GraphType >.

Reimplemented in SVF::VersionedFlowSensitive.

Definition at line 221 of file FlowSensitive.cpp.

222 {
223  SVFGNode* node = svfg->getSVFGNode(nodeId);
224  if (processSVFGNode(node))
225  propagate(&node);
226 
227  clearAllDFOutVarFlag(node);
228 }
void clearAllDFOutVarFlag(const SVFGNode *stmt)
bool processSVFGNode(SVFGNode *node)
SVFGNode * getSVFGNode(NodeID id) const
Get a SVFG node.
Definition: SVFG.h:150
virtual void propagate(GNODE *v)
Definition: WPASolver.h:127

◆ processPhi()

bool FlowSensitive::processPhi ( const PHISVFGNode phi)
protectedvirtual

Process mssa phi node

Definition at line 479 of file FlowSensitive.cpp.

480 {
481  double start = stat->getClk();
482  bool changed = false;
483  NodeID pagDst = phi->getRes()->getId();
484  for (PHISVFGNode::OPVers::const_iterator it = phi->opVerBegin(), eit = phi->opVerEnd(); it != eit; ++it)
485  {
486  NodeID src = it->second->getId();
487  const PointsTo& srcPts = getPts(src);
488  if (unionPts(pagDst, srcPts))
489  changed = true;
490  }
491 
492  double end = stat->getClk();
493  phiTime += (end - start) / TIMEINTERVAL;
494  return changed;
495 }
GEdgeSetTy::const_iterator const_iterator
Definition: GenericGraph.h:406
OPVers::const_iterator opVerBegin() const
Definition: VFGNode.h:707
const PAGNode * getRes() const
Definition: VFGNode.h:699
OPVers::const_iterator opVerEnd() const
Definition: VFGNode.h:711
NodeID getId() const
Get ID.
Definition: GenericGraph.h:260

◆ processStore()

bool FlowSensitive::processStore ( const StoreSVFGNode store)
protectedvirtual

Process store node

foreach node \in dst pts(node) = union pts(src)

STORE statement can only be processed if the pointer on the LHS points to something. If we handle STORE with an empty points-to set, the OUT set will be updated from IN set. Then if LHS pointer points-to one target and it has been identified as a strong update, we can't remove those points-to information computed before this strong update from the OUT set.

check if this is a strong updates store

Reimplemented in SVF::VersionedFlowSensitive.

Definition at line 599 of file FlowSensitive.cpp.

600 {
601 
602  const PointsTo & dstPts = getPts(store->getPAGDstNodeID());
603 
610  if (dstPts.empty())
611  return false;
612 
613  double start = stat->getClk();
614  bool changed = false;
615 
616  // *p = q, the type of q must be a pointer
617  if(getPts(store->getPAGSrcNodeID()).empty() == false && store->getPAGSrcNode()->isPointer())
618  {
619  for (PointsTo::iterator it = dstPts.begin(), eit = dstPts.end(); it != eit; ++it)
620  {
621  NodeID ptd = *it;
622 
623  if (pag->isConstantObj(ptd))
624  continue;
625 
626  if (unionPtsFromTop(store, store->getPAGSrcNodeID(), ptd))
627  changed = true;
628  }
629  }
630 
631  double end = stat->getClk();
632  storeTime += (end - start) / TIMEINTERVAL;
633 
634  double updateStart = stat->getClk();
635  // also merge the DFInSet to DFOutSet.
637  NodeID singleton;
638  bool isSU = isStrongUpdate(store, singleton);
639  if (isSU)
640  {
641  svfgHasSU.set(store->getId());
642  if (strongUpdateOutFromIn(store, singleton))
643  changed = true;
644  }
645  else
646  {
647  svfgHasSU.reset(store->getId());
648  if (weakUpdateOutFromIn(store))
649  changed = true;
650  }
651  double updateEnd = stat->getClk();
652  updateTime += (updateEnd - updateStart) / TIMEINTERVAL;
653 
654  return changed;
655 }
bool isStrongUpdate(const SVFGNode *node, NodeID &singleton)
Return TRUE if this is a strong update STORE statement.
virtual bool unionPtsFromTop(const SVFGNode *stmt, NodeID srcVar, NodeID dstVar)
virtual bool strongUpdateOutFromIn(const SVFGNode *node, NodeID singleton)
Handle strong updates.
virtual bool weakUpdateOutFromIn(const SVFGNode *node)
Handle weak updates.
bool empty() const
Returns true if set is empty.
Definition: PointsTo.cpp:98
void set(unsigned Idx)
void reset(unsigned Idx)
PAGNode * getPAGSrcNode() const
Definition: VFGNode.h:162

◆ processSVFGNode()

bool FlowSensitive::processSVFGNode ( SVFGNode node)
protected

Process each SVFG node

Definition at line 233 of file FlowSensitive.cpp.

234 {
235  double start = stat->getClk();
236  bool changed = false;
237  if (AddrSVFGNode* addr = SVFUtil::dyn_cast<AddrSVFGNode>(node))
238  {
240  if (processAddr(addr))
241  changed = true;
242  }
243  else if (CopySVFGNode* copy = SVFUtil::dyn_cast<CopySVFGNode>(node))
244  {
246  if (processCopy(copy))
247  changed = true;
248  }
249  else if (GepSVFGNode* gep = SVFUtil::dyn_cast<GepSVFGNode>(node))
250  {
252  if(processGep(gep))
253  changed = true;
254  }
255  else if (LoadSVFGNode* load = SVFUtil::dyn_cast<LoadSVFGNode>(node))
256  {
258  if(processLoad(load))
259  changed = true;
260  }
261  else if (StoreSVFGNode* store = SVFUtil::dyn_cast<StoreSVFGNode>(node))
262  {
264  if (processStore(store))
265  changed = true;
266  }
267  else if (PHISVFGNode* phi = SVFUtil::dyn_cast<PHISVFGNode>(node))
268  {
270  if (processPhi(phi))
271  changed = true;
272  }
275  ActualOUTSVFGNode>(node))
276  {
278  changed = true;
279  }
282  NullPtrSVFGNode>(node))
283  {
284  changed = true;
285  }
286  else if (SVFUtil::isa<CmpVFGNode, BinaryOPVFGNode>(node) ||
287  SVFUtil::dyn_cast<UnaryOPVFGNode>(node))
288  {
289  }
290  else
291  {
292  assert(false && "unexpected kind of SVFG nodes");
293  }
294 
295  double end = stat->getClk();
296  processTime += (end - start) / TIMEINTERVAL;
297 
298  return changed;
299 }
virtual bool processLoad(const LoadSVFGNode *load)
virtual bool processPhi(const PHISVFGNode *phi)
virtual bool processStore(const StoreSVFGNode *store)
virtual bool processCopy(const CopySVFGNode *copy)
virtual bool processAddr(const AddrSVFGNode *addr)
virtual bool processGep(const GepSVFGNode *edge)
LLVM_NODISCARD bool isa(const Y &Val)
Definition: Casting.h:241

◆ propagateFromAPToFP()

bool FlowSensitive::propagateFromAPToFP ( const ActualParmSVFGNode ap,
const SVFGNode dst 
)
protectedvirtual

Propagate points-to information from an actual-param to a formal-param. Not necessary if SVFGOPT is used instead of original SVFG.

Propagate points-to information from actual-param to formal-param. Not necessary if SVFGOPT is used instead of original SVFG.

Definition at line 360 of file FlowSensitive.cpp.

361 {
362  const FormalParmSVFGNode* fp = SVFUtil::dyn_cast<FormalParmSVFGNode>(dst);
363  assert(fp && "expecting a formal param node");
364 
365  NodeID pagDst = fp->getParam()->getId();
366  const PointsTo &srcCPts = getPts(ap->getParam()->getId());
367  bool changed = unionPts(pagDst, srcCPts);
368 
369  return changed;
370 }
const PAGNode * getParam() const
Return parameter.
Definition: VFGNode.h:907
const PAGNode * getParam() const
Return parameter.
Definition: VFGNode.h:959

◆ propagateFromFRToAR()

bool FlowSensitive::propagateFromFRToAR ( const FormalRetSVFGNode fr,
const SVFGNode dst 
)
protectedvirtual

Propagate points-to information from a formal-ret to an actual-ret. Not necessary if SVFGOPT is used instead of original SVFG.

Propagate points-to information from formal-ret to actual-ret. Not necessary if SVFGOPT is used instead of original SVFG.

Definition at line 376 of file FlowSensitive.cpp.

377 {
378  const ActualRetSVFGNode* ar = SVFUtil::dyn_cast<ActualRetSVFGNode>(dst);
379  assert(ar && "expecting an actual return node");
380 
381  NodeID pagDst = ar->getRev()->getId();
382  const PointsTo & srcCPts = getPts(fr->getRet()->getId());
383  bool changed = unionPts(pagDst, srcCPts);
384 
385  return changed;
386 }
const PAGNode * getRev() const
Receive parameter at callsite.
Definition: VFGNode.h:1044
const PAGNode * getRet() const
Return value at callee.
Definition: VFGNode.h:1095

◆ propAlongDirectEdge()

bool FlowSensitive::propAlongDirectEdge ( const DirectSVFGEdge edge)
protectedvirtual

Propagate points-to information along a DIRECT SVFG edge.

Propagate points-to information along DIRECT SVFG edge.

Definition at line 329 of file FlowSensitive.cpp.

330 {
331  double start = stat->getClk();
332  bool changed = false;
333 
334  SVFGNode* src = edge->getSrcNode();
335  SVFGNode* dst = edge->getDstNode();
336  // If this is an actual-param or formal-ret, top-level pointer's pts must be
337  // propagated from src to dst.
338  if (ActualParmSVFGNode* ap = SVFUtil::dyn_cast<ActualParmSVFGNode>(src))
339  changed = propagateFromAPToFP(ap, dst);
340  else if (FormalRetSVFGNode* fp = SVFUtil::dyn_cast<FormalRetSVFGNode>(src))
341  changed = propagateFromFRToAR(fp, dst);
342  else
343  {
344  // Direct SVFG edge links between def and use of a top-level pointer.
345  // There's no points-to information propagated along direct edge.
346  // Since the top-level pointer's value has been changed at src node,
347  // return TRUE to put dst node into the work list.
348  changed = true;
349  }
350 
351  double end = stat->getClk();
352  directPropaTime += (end - start) / TIMEINTERVAL;
353  return changed;
354 }
virtual bool propagateFromAPToFP(const ActualParmSVFGNode *ap, const SVFGNode *dst)
virtual bool propagateFromFRToAR(const FormalRetSVFGNode *fr, const SVFGNode *dst)
NodeType * getSrcNode() const
Definition: GenericGraph.h:97
NodeType * getDstNode() const
Definition: GenericGraph.h:101

◆ propAlongIndirectEdge()

bool FlowSensitive::propAlongIndirectEdge ( const IndirectSVFGEdge edge)
protectedvirtual

Propagate points-to information along an INDIRECT SVFG edge.

Propagate points-to information along INDIRECT SVFG edge.

If this is a field-insensitive obj, propagate all field node's pts

Reimplemented in SVF::VersionedFlowSensitive.

Definition at line 391 of file FlowSensitive.cpp.

392 {
393  double start = stat->getClk();
394 
395  SVFGNode* src = edge->getSrcNode();
396  SVFGNode* dst = edge->getDstNode();
397 
398  bool changed = false;
399 
400  // Get points-to targets may be used by next SVFG node.
401  // Propagate points-to set for node used in dst.
402  const NodeBS& pts = edge->getPointsTo();
403  for (NodeBS::iterator ptdIt = pts.begin(), ptdEit = pts.end(); ptdIt != ptdEit; ++ptdIt)
404  {
405  NodeID ptd = *ptdIt;
406 
407  if (propVarPtsFromSrcToDst(ptd, src, dst))
408  changed = true;
409 
410  if (isFieldInsensitive(ptd))
411  {
413  const NodeBS& allFields = getAllFieldsObjVars(ptd);
414  for (NodeBS::iterator fieldIt = allFields.begin(), fieldEit = allFields.end();
415  fieldIt != fieldEit; ++fieldIt)
416  {
417  if (propVarPtsFromSrcToDst(*fieldIt, src, dst))
418  changed = true;
419  }
420  }
421  }
422 
423  double end = stat->getClk();
424  indirectPropaTime += (end - start) / TIMEINTERVAL;
425  return changed;
426 }
virtual bool propVarPtsFromSrcToDst(NodeID var, const SVFGNode *src, const SVFGNode *dst)
Propagate points-to information of a certain variable from src to dst.
const NodeBS & getPointsTo() const
Definition: SVFGEdge.h:60

◆ propDFInToIn()

virtual bool SVF::FlowSensitive::propDFInToIn ( const SVFGNode srcStmt,
NodeID  srcVar,
const SVFGNode dstStmt,
NodeID  dstVar 
)
inlineprotectedvirtual

Definition at line 181 of file FlowSensitive.h.

182  {
183  return getDFPTDataTy()->updateAllDFInFromIn(srcStmt->getId(), srcVar, dstStmt->getId(),dstVar);
184  }
virtual bool updateAllDFInFromIn(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar)=0
Union (IN[dstLoc::dstVar], IN[srcLoc:srcVar]. There is no flag check, unlike the above.

◆ propDFOutToIn()

virtual bool SVF::FlowSensitive::propDFOutToIn ( const SVFGNode srcStmt,
NodeID  srcVar,
const SVFGNode dstStmt,
NodeID  dstVar 
)
inlineprotectedvirtual

Definition at line 177 of file FlowSensitive.h.

178  {
179  return getDFPTDataTy()->updateAllDFInFromOut(srcStmt->getId(), srcVar, dstStmt->getId(),dstVar);
180  }
virtual bool updateAllDFInFromOut(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar)=0
Union (IN[dstLoc::dstVar], OUT[srcLoc:srcVar]. There is no flag check, unlike the above.

◆ propFromSrcToDst()

bool FlowSensitive::propFromSrcToDst ( SVFGEdge edge)
overrideprotected

Propagation.

Propagate points-to information from an edge's src node to its dst node.

Propagate points-to information from source to destination node Union dfOutput of src to dfInput of dst. Only propagate points-to set of node which exists on the SVFG edge.

  1. propagation along direct edge will always return TRUE.
  2. propagation along indirect edge will return TRUE if destination node's IN set has been updated.

Definition at line 309 of file FlowSensitive.cpp.

310 {
311  double start = stat->getClk();
312  bool changed = false;
313 
314  if (DirectSVFGEdge* dirEdge = SVFUtil::dyn_cast<DirectSVFGEdge>(edge))
315  changed = propAlongDirectEdge(dirEdge);
316  else if (IndirectSVFGEdge* indEdge = SVFUtil::dyn_cast<IndirectSVFGEdge>(edge))
317  changed = propAlongIndirectEdge(indEdge);
318  else
319  assert(false && "new kind of svfg edge?");
320 
321  double end = stat->getClk();
322  propagationTime += (end - start) /TIMEINTERVAL;
323  return changed;
324 }
virtual bool propAlongDirectEdge(const DirectSVFGEdge *edge)
Propagate points-to information along a DIRECT SVFG edge.
virtual bool propAlongIndirectEdge(const IndirectSVFGEdge *edge)
Propagate points-to information along an INDIRECT SVFG edge.

◆ propVarPtsAfterCGUpdated()

bool FlowSensitive::propVarPtsAfterCGUpdated ( NodeID  var,
const SVFGNode src,
const SVFGNode dst 
)
protected

Propagation between newly connected SVFG nodes during updateCallGraph. Can only be used during updateCallGraph.

Propagate points-to information of a certain variable from src to dst.

Definition at line 810 of file FlowSensitive.cpp.

811 {
812  if (SVFUtil::isa<StoreSVFGNode>(src))
813  {
814  if (propDFOutToIn(src, var, dst, var))
815  return true;
816  }
817  else
818  {
819  if (propDFInToIn(src, var, dst, var))
820  return true;
821  }
822  return false;
823 }
virtual bool propDFInToIn(const SVFGNode *srcStmt, NodeID srcVar, const SVFGNode *dstStmt, NodeID dstVar)
virtual bool propDFOutToIn(const SVFGNode *srcStmt, NodeID srcVar, const SVFGNode *dstStmt, NodeID dstVar)

◆ propVarPtsFromSrcToDst()

bool FlowSensitive::propVarPtsFromSrcToDst ( NodeID  var,
const SVFGNode src,
const SVFGNode dst 
)
protectedvirtual

Propagate points-to information of a certain variable from src to dst.

Propagate points-to information of a certain variable from src to dst.

Definition at line 431 of file FlowSensitive.cpp.

432 {
433  bool changed = false;
434  if (SVFUtil::isa<StoreSVFGNode>(src))
435  {
436  if (updateInFromOut(src, var, dst, var))
437  changed = true;
438  }
439  else
440  {
441  if (updateInFromIn(src, var, dst, var))
442  changed = true;
443  }
444  return changed;
445 }
virtual bool updateInFromIn(const SVFGNode *srcStmt, NodeID srcVar, const SVFGNode *dstStmt, NodeID dstVar)
virtual bool updateInFromOut(const SVFGNode *srcStmt, NodeID srcVar, const SVFGNode *dstStmt, NodeID dstVar)

◆ PTAName()

const std::string SVF::FlowSensitive::PTAName ( ) const
inlineoverridevirtual

Get PTA name.

Reimplemented from SVF::PointerAnalysis.

Reimplemented in SVF::VersionedFlowSensitive.

Definition at line 117 of file FlowSensitive.h.

118  {
119  return "FlowSensitive";
120  }

◆ readPtsFromFile()

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

Initialization for the Solver

Load the pts from file

finalize the analysis

Reimplemented in SVF::VersionedFlowSensitive.

Definition at line 149 of file FlowSensitive.cpp.

150 {
152  initialize();
154  if(!filename.empty())
155  this->readFromFile(filename);
157  finalize();
158 }
virtual bool readFromFile(const std::string &filename)

◆ releaseFSWPA()

static void SVF::FlowSensitive::releaseFSWPA ( )
inlinestatic

Release flow-sensitive pointer analysis.

Definition at line 90 of file FlowSensitive.h.

91  {
92  fspta = nullptr;
93  }

◆ runOnModule()

virtual bool SVF::FlowSensitive::runOnModule ( SVFModule )
inlinevirtual

We start from here.

Definition at line 96 of file FlowSensitive.h.

97  {
98  return false;
99  }

◆ SCCDetect()

NodeStack & FlowSensitive::SCCDetect ( )
overrideprotectedvirtual

SCC detection.

SCC detection

Reimplemented from SVF::WPAFSSolver< GraphType >.

Definition at line 209 of file FlowSensitive.cpp.

210 {
211  double start = stat->getClk();
213  double end = stat->getClk();
214  sccTime += (end - start) / TIMEINTERVAL;
215  return nodeStack;
216 }
virtual NodeStack & SCCDetect()
SCC detection.
Definition: WPAFSSolver.h:67

◆ solveAndwritePtsToFile()

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

Start analysis

Initialization for the Solver

finalize the analysis

Reimplemented in SVF::VersionedFlowSensitive.

Definition at line 112 of file FlowSensitive.cpp.

113 {
115  initialize();
116  if(!filename.empty())
117  writeObjVarToFile(filename);
119  if(!filename.empty())
120  writeToFile(filename);
122  finalize();
123 }
virtual void writeToFile(const std::string &filename)
Interface for analysis result storage on filesystem.
virtual void writeObjVarToFile(const std::string &filename)

◆ solveConstraints()

void FlowSensitive::solveConstraints ( )
virtual

Start solving constraints

Definition at line 77 of file FlowSensitive.cpp.

78 {
80 
81  double start = stat->getClk(true);
83  DBOUT(DGENERAL, outs() << SVFUtil::pasMsg("Start Solving Constraints\n"));
84 
85  do
86  {
88 
90  dumpStat();
91 
92  callGraphSCC->find();
93 
94  initWorklist();
95  solveWorklist();
96  }
98 
99  DBOUT(DGENERAL, outs() << SVFUtil::pasMsg("Finish Solving Constraints\n"));
100 
101  // Reset the time-up alarm; analysis is done.
102  SVFUtil::stopAnalysisLimitTimer(limitTimerSet);
103 
104  double end = stat->getClk(true);
105  solveTime += (end - start) / TIMEINTERVAL;
106 
107 }
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition: SVFType.h:484
#define DGENERAL
Definition: SVFType.h:490
bool updateCallGraph(const CallSiteToFunPtrMap &callsites) override
Update call graph.
static const Option< u32_t > FsTimeLimit
Time limit for the main phase (i.e., the actual solving) of FS analyses.
Definition: Options.h:72
const CallSiteToFunPtrMap & getIndirectCallsites() const
Return all indirect callsites.
void dumpStat()
Dump the statistics.
CallGraphSCC * callGraphSCC
SCC for PTACallGraph.
void find(void)
Definition: SCC.h:308
virtual void initWorklist()
Definition: WPASolver.h:97
u32_t numOfIteration
num of iterations during constraint solving
Definition: WPASolver.h:200
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
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50

◆ strongUpdateOutFromIn()

virtual bool SVF::FlowSensitive::strongUpdateOutFromIn ( const SVFGNode node,
NodeID  singleton 
)
inlineprotectedvirtual

Handle strong updates.

Definition at line 166 of file FlowSensitive.h.

167  {
168  return getDFPTDataTy()->updateAllDFOutFromIn(node->getId(),singleton,true);
169  }
virtual bool updateAllDFOutFromIn(LocID loc, const Key &singleton, bool strongUpdates)=0
For each variable var in IN at loc, do updateDFOutFromIn(loc, var, loc, var).

◆ svfgStat()

void SVF::FlowSensitive::svfgStat ( )
protected

◆ unionPtsFromIn()

virtual bool SVF::FlowSensitive::unionPtsFromIn ( const SVFGNode stmt,
NodeID  srcVar,
NodeID  dstVar 
)
inlineprotectedvirtual

Definition at line 202 of file FlowSensitive.h.

203  {
204  return getDFPTDataTy()->updateTLVPts(stmt->getId(),srcVar,dstVar);
205  }
virtual bool updateTLVPts(LocID srcLoc, const Key &srcVar, const Key &dstVar)=0
Update points-to set of top-level pointers with IN[srcLoc:srcVar].

◆ unionPtsFromTop()

virtual bool SVF::FlowSensitive::unionPtsFromTop ( const SVFGNode stmt,
NodeID  srcVar,
NodeID  dstVar 
)
inlineprotectedvirtual

Definition at line 206 of file FlowSensitive.h.

207  {
208  return getDFPTDataTy()->updateATVPts(srcVar,stmt->getId(),dstVar);
209  }
virtual bool updateATVPts(const Key &srcVar, LocID dstLoc, const Key &dstVar)=0
Update address-taken variables OUT[dstLoc:dstVar] with points-to of top-level pointers.

◆ updateCallGraph()

bool FlowSensitive::updateCallGraph ( const CallSiteToFunPtrMap callsites)
overrideprotectedvirtual

Update call graph.

Update call graph.

Update call graph

Reimplemented from SVF::BVDataPTAImpl.

Definition at line 687 of file FlowSensitive.cpp.

688 {
689  double start = stat->getClk();
690  CallEdgeMap newEdges;
691  onTheFlyCallGraphSolve(callsites, newEdges);
692 
693  // Bound the new edges by the Andersen's call graph.
694  // TODO: we want this to be an assertion eventually.
695  const CallEdgeMap &andersCallEdgeMap = ander->getIndCallMap();
696  for (typename CallEdgeMap::value_type &csfs : newEdges)
697  {
698  const CallICFGNode *potentialCallSite = csfs.first;
699  FunctionSet &potentialFunctionSet = csfs.second;
700 
701  // Check this callsite even calls anything per Andersen's.
702  typename CallEdgeMap::const_iterator andersFunctionSetIt
703  = andersCallEdgeMap.find(potentialCallSite);
704  if (andersFunctionSetIt == andersCallEdgeMap.end())
705  {
706  potentialFunctionSet.clear();
707  }
708 
709  const FunctionSet &andersFunctionSet = andersFunctionSetIt->second;
710  for (FunctionSet::iterator potentialFunctionIt = potentialFunctionSet.begin();
711  potentialFunctionIt != potentialFunctionSet.end(); )
712  {
713  const SVFFunction *potentialFunction = *potentialFunctionIt;
714  if (andersFunctionSet.find(potentialFunction) == andersFunctionSet.end())
715  {
716  // potentialFunction is not in the Andersen's call graph -- remove it.
717  potentialFunctionIt = potentialFunctionSet.erase(potentialFunctionIt);
718  }
719  else
720  {
721  // potentialFunction is in the Andersen's call graph -- keep it..
722  ++potentialFunctionIt;
723  }
724  }
725  }
726 
727  SVFGEdgeSetTy svfgEdges;
728  connectCallerAndCallee(newEdges, svfgEdges);
729 
730  updateConnectedNodes(svfgEdges);
731 
732  double end = stat->getClk();
733  updateCallGraphTime += (end - start) / TIMEINTERVAL;
734  return (!newEdges.empty());
735 }
virtual void onTheFlyCallGraphSolve(const CallSiteToFunPtrMap &callsites, CallEdgeMap &newEdges)
On the fly call graph construction.
virtual void updateConnectedNodes(const SVFGEdgeSetTy &edges)
Update nodes connected during updating call graph.
SVFG::SVFGEdgeSetTy SVFGEdgeSetTy
Definition: FlowSensitive.h:53
void connectCallerAndCallee(const CallEdgeMap &newEdges, SVFGEdgeSetTy &edges)
Connect nodes in SVFG.
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
OrderedMap< const CallICFGNode *, FunctionSet > CallEdgeMap

◆ updateConnectedNodes()

void FlowSensitive::updateConnectedNodes ( const SVFGEdgeSetTy edges)
protectedvirtual

Update nodes connected during updating call graph.

Push nodes connected during update call graph into worklist so they will be solved during next iteration.

If this is a formal-param or actual-ret node, we need to solve this phi node in next iteration

If this is a formal-in or actual-out node, we need to propagate points-to information from its predecessor node.

If this is a field-insensitive obj, propagate all field node's pts

Reimplemented in SVF::VersionedFlowSensitive.

Definition at line 760 of file FlowSensitive.cpp.

761 {
762  for (const SVFGEdge* edge : edges)
763  {
764  SVFGNode* dstNode = edge->getDstNode();
765  if (SVFUtil::isa<PHISVFGNode>(dstNode))
766  {
769  pushIntoWorklist(dstNode->getId());
770  }
771  else if (SVFUtil::isa<FormalINSVFGNode, ActualOUTSVFGNode>(dstNode))
772  {
775  bool changed = false;
776 
777  SVFGNode* srcNode = edge->getSrcNode();
778 
779  const NodeBS& pts = SVFUtil::cast<IndirectSVFGEdge>(edge)->getPointsTo();
780  for (NodeBS::iterator ptdIt = pts.begin(), ptdEit = pts.end(); ptdIt != ptdEit; ++ptdIt)
781  {
782  NodeID ptd = *ptdIt;
783 
784  if (propVarPtsAfterCGUpdated(ptd, srcNode, dstNode))
785  changed = true;
786 
787  if (isFieldInsensitive(ptd))
788  {
790  const NodeBS& allFields = getAllFieldsObjVars(ptd);
791  for (NodeBS::iterator fieldIt = allFields.begin(), fieldEit = allFields.end();
792  fieldIt != fieldEit; ++fieldIt)
793  {
794  if (propVarPtsAfterCGUpdated(*fieldIt, srcNode, dstNode))
795  changed = true;
796  }
797  }
798  }
799 
800  if (changed)
801  pushIntoWorklist(dstNode->getId());
802  }
803  }
804 }
bool propVarPtsAfterCGUpdated(NodeID var, const SVFGNode *src, const SVFGNode *dst)
virtual void pushIntoWorklist(NodeID id)
Definition: WPASolver.h:156

◆ updateInFromIn()

virtual bool SVF::FlowSensitive::updateInFromIn ( const SVFGNode srcStmt,
NodeID  srcVar,
const SVFGNode dstStmt,
NodeID  dstVar 
)
inlineprotectedvirtual

Definition at line 193 of file FlowSensitive.h.

194  {
195  return getDFPTDataTy()->updateDFInFromIn(srcStmt->getId(),srcVar, dstStmt->getId(),dstVar);
196  }
virtual bool updateDFInFromIn(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar)=0

◆ updateInFromOut()

virtual bool SVF::FlowSensitive::updateInFromOut ( const SVFGNode srcStmt,
NodeID  srcVar,
const SVFGNode dstStmt,
NodeID  dstVar 
)
inlineprotectedvirtual

Definition at line 197 of file FlowSensitive.h.

198  {
199  return getDFPTDataTy()->updateDFInFromOut(srcStmt->getId(),srcVar, dstStmt->getId(),dstVar);
200  }
virtual bool updateDFInFromOut(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar)=0
Union (IN[dstLoc:dstVar], OUT[srcLoc:srcVar]).

◆ updateOutFromIn()

bool SVF::FlowSensitive::updateOutFromIn ( const SVFGNode srcStmt,
NodeID  srcVar,
const SVFGNode dstStmt,
NodeID  dstVar 
)
inlineprotected

Update data-flow points-to data.

Definition at line 189 of file FlowSensitive.h.

190  {
191  return getDFPTDataTy()->updateDFOutFromIn(srcStmt->getId(),srcVar, dstStmt->getId(),dstVar);
192  }
virtual bool updateDFOutFromIn(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar)=0
Union (OUT[dstLoc:dstVar], IN[srcLoc:srcVar]).

◆ weakUpdateOutFromIn()

virtual bool SVF::FlowSensitive::weakUpdateOutFromIn ( const SVFGNode node)
inlineprotectedvirtual

Handle weak updates.

Definition at line 161 of file FlowSensitive.h.

162  {
163  return getDFPTDataTy()->updateAllDFOutFromIn(node->getId(),0,false);
164  }

Friends And Related Function Documentation

◆ FlowSensitiveStat

friend class FlowSensitiveStat
friend

Definition at line 51 of file FlowSensitive.h.

Member Data Documentation

◆ addrTime

double SVF::FlowSensitive::addrTime
protected

time of handling address edges

Definition at line 307 of file FlowSensitive.h.

◆ ander

AndersenWaveDiff* SVF::FlowSensitive::ander
protected

Definition at line 279 of file FlowSensitive.h.

◆ candidateMappings

std::vector<std::pair<hclust_fast_methods, std::vector<NodeID> > > SVF::FlowSensitive::candidateMappings
protected

Save candidate mappings for evaluation's sake.

Definition at line 282 of file FlowSensitive.h.

◆ copyTime

double SVF::FlowSensitive::copyTime
protected

time of handling copy edges

Definition at line 308 of file FlowSensitive.h.

◆ directPropaTime

double SVF::FlowSensitive::directPropaTime
protected

time of points-to propagation of address-taken objects

Definition at line 304 of file FlowSensitive.h.

◆ fspta

std::unique_ptr< FlowSensitive > FlowSensitive::fspta
staticprotected

Definition at line 277 of file FlowSensitive.h.

◆ gepTime

double SVF::FlowSensitive::gepTime
protected

time of handling gep edges

Definition at line 309 of file FlowSensitive.h.

◆ indirectPropaTime

double SVF::FlowSensitive::indirectPropaTime
protected

time of points-to propagation of top-level pointers

Definition at line 305 of file FlowSensitive.h.

◆ loadTime

double SVF::FlowSensitive::loadTime
protected

time of load edges

Definition at line 310 of file FlowSensitive.h.

◆ maxSCCSize

u32_t SVF::FlowSensitive::maxSCCSize
protected

Number of processed mssa node.

Definition at line 296 of file FlowSensitive.h.

◆ memSSA

SVFGBuilder SVF::FlowSensitive::memSSA
protected

Definition at line 278 of file FlowSensitive.h.

◆ numOfNodesInSCC

u32_t SVF::FlowSensitive::numOfNodesInSCC
protected

Definition at line 298 of file FlowSensitive.h.

◆ numOfProcessedActualParam

u32_t SVF::FlowSensitive::numOfProcessedActualParam
protected

Number of processed Store node.

Definition at line 292 of file FlowSensitive.h.

◆ numOfProcessedAddr

u32_t SVF::FlowSensitive::numOfProcessedAddr
protected

Statistics.

Definition at line 286 of file FlowSensitive.h.

◆ numOfProcessedCopy

u32_t SVF::FlowSensitive::numOfProcessedCopy
protected

Number of processed Addr node.

Definition at line 287 of file FlowSensitive.h.

◆ numOfProcessedFormalRet

u32_t SVF::FlowSensitive::numOfProcessedFormalRet
protected

Number of processed actual param node.

Definition at line 293 of file FlowSensitive.h.

◆ numOfProcessedGep

u32_t SVF::FlowSensitive::numOfProcessedGep
protected

Number of processed Copy node.

Definition at line 288 of file FlowSensitive.h.

◆ numOfProcessedLoad

u32_t SVF::FlowSensitive::numOfProcessedLoad
protected

Number of processed Phi node.

Definition at line 290 of file FlowSensitive.h.

◆ numOfProcessedMSSANode

u32_t SVF::FlowSensitive::numOfProcessedMSSANode
protected

Number of processed formal ret node.

Definition at line 294 of file FlowSensitive.h.

◆ numOfProcessedPhi

u32_t SVF::FlowSensitive::numOfProcessedPhi
protected

Number of processed Gep node.

Definition at line 289 of file FlowSensitive.h.

◆ numOfProcessedStore

u32_t SVF::FlowSensitive::numOfProcessedStore
protected

Number of processed Load node.

Definition at line 291 of file FlowSensitive.h.

◆ numOfSCC

u32_t SVF::FlowSensitive::numOfSCC
protected

Definition at line 297 of file FlowSensitive.h.

◆ phiTime

double SVF::FlowSensitive::phiTime
protected

time of phi nodes.

Definition at line 312 of file FlowSensitive.h.

◆ processTime

double SVF::FlowSensitive::processTime
protected

time of processNode.

Definition at line 302 of file FlowSensitive.h.

◆ propagationTime

double SVF::FlowSensitive::propagationTime
protected

time of points-to propagation.

Definition at line 303 of file FlowSensitive.h.

◆ sccTime

double SVF::FlowSensitive::sccTime
protected

time of SCC detection.

Definition at line 301 of file FlowSensitive.h.

◆ solveTime

double SVF::FlowSensitive::solveTime
protected

time of solve.

Definition at line 300 of file FlowSensitive.h.

◆ storeTime

double SVF::FlowSensitive::storeTime
protected

time of store edges

Definition at line 311 of file FlowSensitive.h.

◆ svfg

SVFG* SVF::FlowSensitive::svfg
protected

Definition at line 245 of file FlowSensitive.h.

◆ svfgHasSU

NodeBS SVF::FlowSensitive::svfgHasSU
protected

Definition at line 315 of file FlowSensitive.h.

◆ updateCallGraphTime

double SVF::FlowSensitive::updateCallGraphTime
protected

time of updating call graph

Definition at line 313 of file FlowSensitive.h.

◆ updateTime

double SVF::FlowSensitive::updateTime
protected

time of strong/weak updates.

Definition at line 306 of file FlowSensitive.h.


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