Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
SVF::FSMPTA< SVFGGraph > Class Template Referencefinal

#include <FSMPTA.h>

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

Public Member Functions

 FSMPTA (AndersenWaveDiff &preAnalysis, SVFG &backingGraph, SVFGGraph solveGraph)
 
 ~FSMPTA () override=default
 
void initialize () override
 Initialize analysis.
 
void finalize () override
 Finalize analysis.
 
- Public Member Functions inherited from SVF::FlowSensitive
 FlowSensitive (SVFIR *_pag, PTATY type=PTATY::FSSPARSE_WPA)
 Constructor.
 
 ~FlowSensitive () override=default
 Destructor.
 
virtual bool runOnModule ()
 We start from here.
 
void analyze () override
 Flow sensitive analysis.
 
virtual void solveAndwritePtsToFile (const std::string &filename)
 
virtual void readPtsFromFile (const std::string &filename)
 
virtual void solveConstraints ()
 
const std::string PTAName () const override
 Get PTA name.
 
SVFGgetSVFG () const
 Return SVFG.
 
- Public Member Functions inherited from SVF::WPAFSSolver< GraphType >
 WPAFSSolver ()
 Constructor.
 
virtual ~WPAFSSolver ()
 Destructor.
 
virtual NodeID sccRepNode (NodeID id) const
 SCC methods.
 
- Public Member Functions inherited from SVF::BVDataPTAImpl
 BVDataPTAImpl (SVFIR *pag, PTATY type, bool alias_check=true)
 Constructor.
 
 ~BVDataPTAImpl () override=default
 Destructor.
 
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.
 
virtual void clearFullPts (NodeID id)
 Clear points-to set of id.
 
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.
 
virtual void expandFIObjs (const PointsTo &pts, PointsTo &expandedPts)
 Expand FI objects.
 
virtual void expandFIObjs (const NodeBS &pts, NodeBS &expandedPts)
 TODO: remove repetition.
 
void remapPointsToSets (void)
 Remap all points-to sets to use the current mapping.
 
virtual void writeToFile (const std::string &filename)
 Interface for analysis result storage on filesystem.
 
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 SVFVar *V1, const SVFVar *V2) override
 Interface expose to users of our pointer analysis, given Value infos.
 
AliasResult alias (NodeID node1, NodeID node2) override
 Interface expose to users of our pointer analysis, given PAGNodeID.
 
virtual AliasResult alias (const PointsTo &pts1, const PointsTo &pts2)
 Interface expose to users of our pointer analysis, given two pts.
 
bool mayAlias (const PointsTo &pts1, const PointsTo &pts2)
 Convenience bool wrappers: return true if the two operands may/must/partial alias.
 
void dumpCPts () override
 dump and debug, print out conditional pts
 
void dumpTopLevelPtsTo () override
 
void dumpAllPts () override
 
- Public Member Functions inherited from SVF::PointerAnalysis
ICFGgetICFG () const
 Get ICFG.
 
u32_t getNumOfResolvedIndCallEdge () const
 Return number of resolved indirect call edges.
 
CallGraphgetCallGraph () const
 Return call graph.
 
CallGraphSCCgetCallGraphSCC () const
 Return call graph SCC.
 
 PointerAnalysis (SVFIR *pag, PTATY ty=PTATY::Default_PTA, bool alias_check=true)
 Constructor.
 
PTATY getAnalysisTy () const
 Type of pointer analysis.
 
PTAImplTy getImplTy () const
 Return implementation type of the pointer analysis.
 
bool printStat ()
 Whether print statistics.
 
void disablePrintStat ()
 Whether print statistics.
 
CallEdgeMapgetIndCallMap ()
 Get callees from an indirect callsite.
 
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.
 
void callGraphSCCDetection ()
 PTACallGraph SCC related methods.
 
NodeID getCallGraphSCCRepNode (NodeID id) const
 Get SCC rep node of a SVFG node.
 
bool inSameCallGraphSCC (const FunObjVar *fun1, const FunObjVar *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.
 
bool isInRecursion (const FunObjVar *fun) const
 
bool isLocalVarInRecursiveFun (NodeID id) const
 Whether a local variable is in function recursions.
 
CommonCHGraphgetCHGraph () const
 get CHGraph
 
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.
 
SVFIRgetPAG () const
 
PTAStatgetStat () const
 Get PTA stat.
 
OrderedNodeSetgetAllValidPtrs ()
 Get all Valid Pointers for resolution.
 
virtual void computeDDAPts (NodeID)
 Compute points-to results on-demand, overridden by derived classes.
 
bool mayAlias (const SVFVar *V1, const SVFVar *V2)
 Convenience bool wrappers: return true if the two operands may/must/partial alias.
 
bool mayAlias (NodeID node1, NodeID node2)
 
void printIndCSTargets (const CallICFGNode *cs, const FunctionSet &targets)
 Print targets of a function pointer.
 
virtual void dumpPts (NodeID ptr, const PointsTo &pts)
 
void printIndCSTargets ()
 
void dumpAllTypes ()
 
void dumpStat ()
 Dump the statistics.
 
bool containBlackHoleNode (const PointsTo &pts)
 Determine whether a points-to contains a black hole or constant node.
 
bool containConstantNode (const PointsTo &pts)
 
virtual bool isBlkObjOrConstantObj (NodeID ptd) const
 
bool isHeapMemObj (NodeID id) const
 Whether this object is heap or array.
 
bool isArrayMemObj (NodeID id) const
 
bool isFIObjNode (NodeID id) const
 
NodeID getBaseObjVarID (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 supportsCurrentConfiguration ()
 
static NodeBS buildExecutionDependencyClosure (SVFG *graph, AndersenBase *preAnalysis, NodeBS dependencyNodes)
 
- Static Public Member Functions inherited from SVF::FlowSensitive
static FlowSensitivecreateFSWPA (SVFIR *_pag)
 Create single instance of flow-sensitive pointer analysis.
 
static void releaseFSWPA ()
 Release flow-sensitive pointer analysis.
 
static bool classof (const FlowSensitive *)
 Methods for support type inquiry through isa, cast, and dyn_cast.
 
static bool classof (const PointerAnalysis *pta)
 
- Static Public Member Functions inherited from SVF::BVDataPTAImpl
static bool classof (const PointerAnalysis *pta)
 

Protected Member Functions

NodeStackSCCDetect () override
 SCC detection.
 
void processNode (NodeID nodeId) override
 Handle various constraints.
 
void updateConnectedNodes (const SVFGEdgeSetTy &edges) override
 Update nodes connected during updating call graph.
 
- Protected Member Functions inherited from SVF::FlowSensitive
bool propFromSrcToDst (SVFGEdge *edge) override
 Propagation.
 
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.
 
virtual bool propVarPtsFromSrcToDst (NodeID var, const SVFGNode *src, const SVFGNode *dst)
 Propagate points-to information of a certain variable from src to dst.
 
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.
 
virtual bool strongUpdateOutFromIn (const SVFGNode *node, NodeID singleton)
 Handle strong updates.
 
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.
 
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)
 
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.
 
void connectCallerAndCallee (const CallEdgeMap &newEdges, SVFGEdgeSetTy &edges)
 Connect nodes in SVFG.
 
bool isStrongUpdate (const SVFGNode *node, NodeID &singleton)
 Return TRUE if this is a strong update STORE statement.
 
virtual void countAliases (Set< std::pair< NodeID, NodeID > > cmp, unsigned *mayAliases, unsigned *noAliases)
 Fills may/noAliases for the location/pointer pairs in cmp.
 
const PointsTogetDFInPtsSet (const SVFGNode *stmt, const NodeID node)
 Get points-to set for a node from data flow IN/OUT set at a statement.
 
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.
 
void svfgStat ()
 
const DFInOutMapgetDFInputMap () const
 
const DFInOutMapgetDFOutputMap () const
 
- Protected Member Functions inherited from SVF::WPASolver< GraphType >
 WPASolver ()
 Constructor.
 
virtual ~WPASolver ()=default
 Destructor.
 
SCCgetSCCDetector () const
 Get SCC detector.
 
const GraphType graph ()
 Get/Set graph methods.
 
void setGraph (GraphType g)
 
virtual NodeStackSCCDetect (NodeSet &candidates)
 
virtual void initWorklist ()
 
virtual void solveWorklist ()
 
virtual void collapseFields ()
 collapse positive weight cycles of a graph
 
virtual void propagate (GNODE *v)
 
virtual bool propFromSrcToDst (GEDGE *)
 Propagate information from source to destination node, to be implemented in the child class.
 
NodeID popFromWorklist ()
 Worklist operations.
 
virtual void pushIntoWorklist (NodeID id)
 
bool isWorklistEmpty ()
 
bool isInWorklist (NodeID id)
 
GNODENode (NodeID id)
 Get node on the graph.
 
NodeID Node_Index (GNODE node)
 Get node ID.
 
- Protected Member Functions inherited from SVF::BVDataPTAImpl
PTDataTygetPTDataTy () const
 Get points-to data structure.
 
DiffPTDataTygetDiffPTDataTy () const
 
DFPTDataTygetDFPTDataTy () const
 
MutDFPTDataTygetMutDFPTDataTy () const
 
VersionedPTDataTygetVersionedPTDataTy () const
 
virtual void onTheFlyCallGraphSolve (const CallSiteToFunPtrMap &callsites, CallEdgeMap &newEdges)
 On the fly call graph construction.
 
virtual void onTheFlyThreadCallGraphSolve (const CallSiteToFunPtrMap &callsites, CallEdgeMap &newForkEdges)
 On the fly thread call graph construction respecting forksite.
 
virtual void normalizePointsTo ()
 
- Protected Member Functions inherited from SVF::PointerAnalysis
const CallSiteToFunPtrMapgetIndirectCallsites () const
 Return all indirect callsites.
 
NodeID getFunPtr (const CallICFGNode *cs) const
 Return function pointer PAGNode at a callsite cs.
 
virtual void validateTests ()
 Alias check functions to verify correctness of pointer analysis.
 
virtual void validateSuccessTests (std::string fun)
 
virtual void validateExpectedFailureTests (std::string fun)
 
void resetObjFieldSensitive ()
 Reset all object node as field-sensitive.
 

Private Types

using SolveGraphTraits = GenericGraphTraits< SVFGGraph >
 

Private Member Functions

void buildRetainedAdjacency ()
 
void cacheRetainedEdge (SVFGEdge *edge)
 

Static Private Member Functions

static void enqueueSVFGNode (const SVFGNode *node, NodeBS &retained, std::deque< NodeID > &worklist)
 
static void demandTopLevelPointer (const SVFVar *var, SVFG *graph, NodeBS &demandedVars, NodeBS &retained, std::deque< NodeID > &worklist)
 
static void collectNodeInputDependencies (const SVFGNode *node, SVFG *graph, NodeBS &demandedVars, NodeBS &retained, std::deque< NodeID > &worklist)
 

Private Attributes

AndersenWaveDiffpreAnalysis
 
SVFGbackingGraph
 
SVFGGraph solveGraph
 
std::unique_ptr< SCCDetection< SVFGGraph > > solveSCC
 
NodeStack solveNodeStack
 
Map< NodeID, std::vector< SVFGEdge * > > retainedOutEdges
 
Set< const SVFGEdge * > retainedEdgeSet
 

Additional Inherited Members

- Public Types inherited from SVF::FlowSensitive
typedef BVDataPTAImpl::MutDFPTDataTy MutDFPTDataTy
 
typedef BVDataPTAImpl::MutDFPTDataTy::DFPtsMap DFInOutMap
 
typedef BVDataPTAImpl::MutDFPTDataTy::PtsMap PtsMap
 
- Public Types inherited from SVF::WPASolver< GraphType >
typedef SVF::GenericGraphTraits< GraphTypeGTraits
 Define the GTraits and node iterator for printing.
 
typedef GTraits::NodeRef GNODE
 
typedef GTraits::EdgeType GEDGE
 
typedef GTraits::ChildIteratorType child_iterator
 
typedef SCCDetection< GraphTypeSCC
 
typedef FIFOWorkList< NodeIDWorkList
 
- Public Types inherited from SVF::BVDataPTAImpl
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
typedef Set< const CallICFGNode * > CallSiteSet
 Indirect call edges type, map a callsite to a set of callees.
 
typedef SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap
 
typedef Set< const FunObjVar * > FunctionSet
 
typedef OrderedMap< const CallICFGNode *, FunctionSetCallEdgeMap
 
typedef SCCDetection< CallGraph * > CallGraphSCC
 
typedef Set< const GlobalObjVar * > VTableSet
 
typedef Set< const FunObjVar * > VFunSet
 
- Public Attributes inherited from SVF::WPASolver< GraphType >
u32_t numOfIteration
 num of iterations during constraint solving
 
- 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 Types inherited from SVF::FlowSensitive
typedef SVFG::SVFGEdgeSetTy SVFGEdgeSetTy
 
- Protected Attributes inherited from SVF::FlowSensitive
SVFGsvfg
 
SVFGBuilder memSSA
 
AndersenWaveDiffander
 
std::vector< std::pair< hclust_fast_methods, std::vector< NodeID > > > candidateMappings
 Save candidate mappings for evaluation's sake.
 
u32_t numOfProcessedAddr
 Statistics.
 
u32_t numOfProcessedCopy
 Number of processed Addr node.
 
u32_t numOfProcessedGep
 Number of processed Copy node.
 
u32_t numOfProcessedPhi
 Number of processed Gep node.
 
u32_t numOfProcessedLoad
 Number of processed Phi node.
 
u32_t numOfProcessedStore
 Number of processed Load node.
 
u32_t numOfProcessedActualParam
 Number of processed Store node.
 
u32_t numOfProcessedFormalRet
 Number of processed actual param node.
 
u32_t numOfProcessedMSSANode
 Number of processed formal ret node.
 
u32_t maxSCCSize
 Number of processed mssa node.
 
u32_t numOfSCC
 
u32_t numOfNodesInSCC
 
double solveTime
 time of solve.
 
double sccTime
 time of SCC detection.
 
double processTime
 time of processNode.
 
double propagationTime
 time of points-to propagation.
 
double directPropaTime
 time of points-to propagation of address-taken objects
 
double indirectPropaTime
 time of points-to propagation of top-level pointers
 
double updateTime
 time of strong/weak updates.
 
double addrTime
 time of handling address edges
 
double copyTime
 time of handling copy edges
 
double gepTime
 time of handling gep edges
 
double loadTime
 time of load edges
 
double storeTime
 time of store edges
 
double phiTime
 time of phi nodes.
 
double updateCallGraphTime
 time of updating call graph
 
NodeBS svfgHasSU
 
- Protected Attributes inherited from SVF::WPAFSSolver< GraphType >
NodeStack nodeStack
 stack used for processing nodes.
 
- Protected Attributes inherited from SVF::WPASolver< GraphType >
bool reanalyze
 Reanalyze if any constraint value changed.
 
u32_t iterationForPrintStat
 print out statistics for i-th iteration
 
GraphType _graph
 Graph.
 
std::unique_ptr< SCCscc
 SCC.
 
WorkList worklist
 Worklist for resolution.
 
- Protected Attributes inherited from SVF::PointerAnalysis
bool print_stat
 User input flags.
 
bool alias_validation
 Flag for validating points-to/alias results.
 
u32_t OnTheFlyIterBudgetForStat
 Flag for iteration budget for on-the-fly statistics.
 
PTATY ptaTy
 Pointer analysis Type.
 
PTAImplTy ptaImplTy
 PTA implementation type.
 
PTAStatstat
 Statistics.
 
CallGraphcallgraph
 Call graph used for pointer analysis.
 
CallGraphSCCcallGraphSCC
 SCC for PTACallGraph.
 
ICFGicfg
 Interprocedural control-flow graph.
 
CommonCHGraphchgraph
 CHGraph.
 
- Static Protected Attributes inherited from SVF::FlowSensitive
static std::unique_ptr< FlowSensitivefspta
 
- Static Protected Attributes inherited from SVF::PointerAnalysis
static SVFIRpag = nullptr
 SVFIR.
 

Detailed Description

template<class SVFGGraph>
class SVF::FSMPTA< SVFGGraph >

Flow-sensitive solver over an already-built thread-aware SVFG. SVFGGraph is either SVFG* for the whole graph or const SlicedSVFGView* for an exact slice. The backing SVFG is owned by MTASVFGBuilder; this class owns only the analysis state and the SCC detector for its solve graph.

Definition at line 54 of file FSMPTA.h.

Member Typedef Documentation

◆ SolveGraphTraits

template<class SVFGGraph >
using SVF::FSMPTA< SVFGGraph >::SolveGraphTraits = GenericGraphTraits<SVFGGraph>
private

Definition at line 80 of file FSMPTA.h.

Constructor & Destructor Documentation

◆ FSMPTA()

template<class SVFGGraph >
FSMPTA::FSMPTA ( AndersenWaveDiff preAnalysis,
SVFG backingGraph,
SVFGGraph  solveGraph 
)

Definition at line 42 of file FSMPTA.cpp.

46{
47}
SVFG * backingGraph
Definition FSMPTA.h:94
SVFGGraph solveGraph
Definition FSMPTA.h:95
AndersenWaveDiff * preAnalysis
Definition FSMPTA.h:93
const GraphType graph()
Get/Set graph methods.
Definition WPASolver.h:75
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ ~FSMPTA()

template<class SVFGGraph >
SVF::FSMPTA< SVFGGraph >::~FSMPTA ( )
overridedefault

Member Function Documentation

◆ buildExecutionDependencyClosure()

template<class SVFGGraph >
NodeBS FSMPTA::buildExecutionDependencyClosure ( SVFG graph,
AndersenBase preAnalysis,
NodeBS  dependencyNodes 
)
static

Close a backward value-flow slice over FlowSensitive's execution dependencies. Besides explicit SVFG predecessors, this follows the definition of every top-level pointer read through the solver-global points-to map, closes future indirect-call boundary edges, and retains variant-GEP transfers whose field-sensitivity side effect is global.

Definition at line 121 of file FSMPTA.cpp.

123{
124 if (graph == nullptr || preAnalysis == nullptr)
125 {
126 SVFUtil::errs() << "[ERROR] FSMPTA execution closure requires a BaseSVFG "
127 << "and Andersen targets\n";
128 return NodeBS();
129 }
130
131 std::deque<NodeID> nodeWorklist;
132 for (NodeID id : dependencyNodes)
134
136 // FlowSensitive::solveConstraints invokes updateCallGraph() for the whole
137 // program after every iteration. Its function-pointer reads are therefore
138 // execution roots even when the call site is not itself in the target slice.
139 SVFIR* pag = graph->getPAG();
140 for (const auto& callsiteAndPtr : pag->getIndirectCallsites())
141 {
142 const SVFVar* funPtr = pag->getGNode(callsiteAndPtr.second);
145 }
146
149 for (const auto& callsiteAndPtr : pag->getIndirectCallsites())
151 for (const auto& callsiteAndTargets : preAnalysis->getIndCallMap())
153 indirectTargets.insert(target);
154
155 // One backing-SVFG pass collects both kinds of solver-global roots:
156 // updateCallGraph boundary nodes and variant-GEP side effects.
157 for (SVFG::const_iterator it = graph->begin(), eit = graph->end();
158 it != eit; ++it)
159 {
160 const SVFGNode* node = it->second;
161 bool boundary = false;
162 if (const ActualParmSVFGNode* actual =
163 SVFUtil::dyn_cast<ActualParmSVFGNode>(node))
164 boundary = indirectSites.count(actual->getCallSite()) > 0;
165 else if (const ActualRetSVFGNode* actual =
166 SVFUtil::dyn_cast<ActualRetSVFGNode>(node))
167 boundary = indirectSites.count(actual->getCallSite()) > 0;
168 else if (const ActualINSVFGNode* actual =
169 SVFUtil::dyn_cast<ActualINSVFGNode>(node))
170 boundary = indirectSites.count(actual->getCallSite()) > 0;
171 else if (const ActualOUTSVFGNode* actual =
172 SVFUtil::dyn_cast<ActualOUTSVFGNode>(node))
173 boundary = indirectSites.count(actual->getCallSite()) > 0;
174 else if (const FormalParmSVFGNode* formal =
175 SVFUtil::dyn_cast<FormalParmSVFGNode>(node))
176 boundary = indirectTargets.count(formal->getFun()) > 0;
177 else if (const FormalRetSVFGNode* formal =
178 SVFUtil::dyn_cast<FormalRetSVFGNode>(node))
179 boundary = indirectTargets.count(formal->getFun()) > 0;
180 else if (const FormalINSVFGNode* formal =
181 SVFUtil::dyn_cast<FormalINSVFGNode>(node))
183 formal->getFunEntryNode()->getFun()) > 0;
184 else if (const FormalOUTSVFGNode* formal =
185 SVFUtil::dyn_cast<FormalOUTSVFGNode>(node))
187 formal->getFunExitNode()->getFun()) > 0;
188 else if (const InterMSSAPHISVFGNode* phi =
189 SVFUtil::dyn_cast<InterMSSAPHISVFGNode>(node))
190 boundary = phi->isFormalINPHI()
191 ? indirectTargets.count(phi->getFun()) > 0
192 : indirectSites.count(phi->getCallSite()) > 0;
193
194 if (boundary)
196
197 // A variant GEP changes field-sensitivity globally. Later transfers
198 // read that state without an explicit SVFG edge.
199 if (const GepSVFGNode* gep = SVFUtil::dyn_cast<GepSVFGNode>(node))
200 {
201 const GepStmt* stmt = SVFUtil::cast<GepStmt>(gep->getSVFStmt());
202 if (stmt->isVariantFieldGep())
204 }
205 }
206
207 // Joint fixed point: explicit SVFG predecessors carry direct/MemorySSA
208 // dependencies; definition roots cover FlowSensitive's implicit reads from
209 // the solver-global top-level points-to relation.
210 while (!nodeWorklist.empty())
211 {
212 const NodeID id = nodeWorklist.front();
213 nodeWorklist.pop_front();
214 const SVFGNode* node = graph->getSVFGNode(id);
215
216 for (const SVFGEdge* edge : node->getInEdges())
218 edge->getSrcNode(), dependencyNodes, nodeWorklist);
219
222 }
223 return dependencyNodes;
224}
for(i=0;a &&(i<(size_t) count);i++)
Definition cJSON.cpp:2569
int count
Definition cJSON.h:216
static void enqueueSVFGNode(const SVFGNode *node, NodeBS &retained, std::deque< NodeID > &worklist)
Definition FSMPTA.cpp:57
static void demandTopLevelPointer(const SVFVar *var, SVFG *graph, NodeBS &demandedVars, NodeBS &retained, std::deque< NodeID > &worklist)
Definition FSMPTA.cpp:69
static void collectNodeInputDependencies(const SVFGNode *node, SVFG *graph, NodeBS &demandedVars, NodeBS &retained, std::deque< NodeID > &worklist)
Definition FSMPTA.cpp:86
IDToNodeMapTy::const_iterator const_iterator
NodeType * getGNode(NodeID id) const
Get a node.
bool isVariantFieldGep() const
Gep statement with a variant field index (pointer arithmetic) for struct field access.
const CallSiteToFunPtrMap & getIndirectCallsites() const
Return all indirect callsites.
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
static SVFIR * pag
SVFIR.
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:120
std::ostream & errs()
Overwrite llvm::errs()
Definition SVFUtil.h:58
u32_t NodeID
Definition GeneralType.h:76
SparseBitVector NodeBS
Definition GeneralType.h:82

◆ buildRetainedAdjacency()

template<class SVFGGraph >
void FSMPTA::buildRetainedAdjacency ( )
private

Definition at line 271 of file FSMPTA.cpp.

272{
273 for (SVFG::iterator it = svfg->begin(), eit = svfg->end(); it != eit; ++it)
274 {
275 SVFGNode* node = it->second;
276 if (!SolveGraphTraits::containsNode(solveGraph, node))
277 continue;
278 for (SVFGEdge* edge : node->getOutEdges())
280 }
281}
void cacheRetainedEdge(SVFGEdge *edge)
Definition FSMPTA.cpp:263
iterator begin()
Iterators.
IDToNodeMapTy::iterator iterator
Node Iterators.

◆ cacheRetainedEdge()

template<class SVFGGraph >
void FSMPTA::cacheRetainedEdge ( SVFGEdge edge)
private

Definition at line 263 of file FSMPTA.cpp.

264{
265 if (SolveGraphTraits::containsEdge(solveGraph, edge) &&
266 retainedEdgeSet.insert(edge).second)
267 retainedOutEdges[edge->getSrcID()].push_back(edge);
268}
Map< NodeID, std::vector< SVFGEdge * > > retainedOutEdges
Definition FSMPTA.h:98
Set< const SVFGEdge * > retainedEdgeSet
Definition FSMPTA.h:99

◆ collectNodeInputDependencies()

template<class SVFGGraph >
void FSMPTA::collectNodeInputDependencies ( const SVFGNode node,
SVFG graph,
NodeBS demandedVars,
NodeBS retained,
std::deque< NodeID > &  nodeWorklist 
)
staticprivate

Register every solver-global top-level points-to read performed while a node is processed. MemorySSA IN/OUT state is carried by explicit indirect SVFG predecessors and therefore needs no separate variable root here.

Definition at line 86 of file FSMPTA.cpp.

89{
90 if (const CopySVFGNode* copy = SVFUtil::dyn_cast<CopySVFGNode>(node))
93 else if (const GepSVFGNode* gep = SVFUtil::dyn_cast<GepSVFGNode>(node))
96 else if (const PHISVFGNode* phi = SVFUtil::dyn_cast<PHISVFGNode>(node))
97 for (auto it = phi->opVerBegin(), eit = phi->opVerEnd(); it != eit; ++it)
100 else if (const LoadSVFGNode* load = SVFUtil::dyn_cast<LoadSVFGNode>(node))
101 demandTopLevelPointer(load->getSrcNode(), graph, demandedVars,
103 else if (const StoreSVFGNode* store = SVFUtil::dyn_cast<StoreSVFGNode>(node))
104 {
105 demandTopLevelPointer(store->getDstNode(), graph, demandedVars,
107 demandTopLevelPointer(store->getSrcNode(), graph, demandedVars,
109 }
110 else if (const ActualParmSVFGNode* actual =
111 SVFUtil::dyn_cast<ActualParmSVFGNode>(node))
114 else if (const FormalRetSVFGNode* formal =
115 SVFUtil::dyn_cast<FormalRetSVFGNode>(node))
118}
copy
Definition cJSON.cpp:414

◆ demandTopLevelPointer()

template<class SVFGGraph >
void FSMPTA::demandTopLevelPointer ( const SVFVar var,
SVFG graph,
NodeBS demandedVars,
NodeBS retained,
std::deque< NodeID > &  worklist 
)
staticprivate

Definition at line 69 of file FSMPTA.cpp.

72{
73 const ValVar* val = SVFUtil::dyn_cast<ValVar>(var);
74 if (val == nullptr || !val->isPointer() || demandedVars.test(val->getId()))
75 return;
76
77 demandedVars.set(val->getId());
78 if (graph->hasDefSVFGNode(val))
79 enqueueSVFGNode(graph->getDefSVFGNode(val), retained, nodeWorklist);
80}

◆ enqueueSVFGNode()

template<class SVFGGraph >
void FSMPTA::enqueueSVFGNode ( const SVFGNode node,
NodeBS retained,
std::deque< NodeID > &  worklist 
)
staticprivate

Definition at line 57 of file FSMPTA.cpp.

60{
61 if (node != nullptr && !retained.test(node->getId()))
62 {
63 retained.set(node->getId());
64 nodeWorklist.push_back(node->getId());
65 }
66}
NodeID getId() const
Get ID.
Definition SVFValue.h:158

◆ finalize()

template<class SVFGGraph >
void FSMPTA::finalize ( )
overridevirtual

Finalize analysis.

Finalize analysis

Reimplemented from SVF::FlowSensitive.

Definition at line 255 of file FSMPTA.cpp.

256{
257 if (Options::DumpVFG())
258 svfg->dump("fs_solved", true);
260}
void finalize() override
Finalization of pointer analysis, and normalize points-to information to Bit Vector representation.
static const Option< bool > DumpVFG
Definition Options.h:107
void dump(const std::string &file, bool simple=false)
Dump graph into dot file.
Definition SVFG.cpp:576

◆ initialize()

template<class SVFGGraph >
void FSMPTA::initialize ( )
overridevirtual

Initialize analysis.

Initialize analysis

Reimplemented from SVF::FlowSensitive.

Definition at line 227 of file FSMPTA.cpp.

228{
230 stat = new FlowSensitiveStat(this);
231 // SlicedMTA reports the deployment-facing result summary. Avoid the generic
232 // FlowSensitive statistics pass because it recomputes SCCs on the full SVFG.
234
236 {
237 SVFUtil::errs() << "[ERROR] FSMPTA does not support clustered Andersen, "
238 << "clustered FS, or plain FS mappings\n";
239 std::abort();
240 }
241
242 // Reuse both the Andersen result and the already-built base SVFG. The main
243 // ILA overlay has been attached by SlicedMTA before analysis starts.
246 // Retain the stock graph handle for FlowSensitive's dynamic-call support;
247 // SCC/worklist topology is supplied exclusively by solveSCC below.
248 setGraph(svfg);
249 solveSCC = std::make_unique<SCCDetection<SVFGGraph>>(solveGraph);
250 if constexpr (SolveGraphTraits::isFilteredGraph)
252}
void buildRetainedAdjacency()
Definition FSMPTA.cpp:271
std::unique_ptr< SCCDetection< SVFGGraph > > solveSCC
Definition FSMPTA.h:96
static bool supportsCurrentConfiguration()
Definition FSMPTA.cpp:50
AndersenWaveDiff * ander
friend class FlowSensitiveStat
virtual void initialize()
Initialization of a pointer analysis, including building symbol table and SVFIR etc.
PTAStat * stat
Statistics.
void disablePrintStat()
Whether print statistics.
void setGraph(GraphType g)
Definition WPASolver.h:79

◆ processNode()

template<class SVFGGraph >
void FSMPTA::processNode ( NodeID  nodeId)
overrideprotectedvirtual

Handle various constraints.

Process each SVFG node

Reimplemented from SVF::FlowSensitive.

Definition at line 309 of file FSMPTA.cpp.

310{
312 assert(SolveGraphTraits::containsNode(solveGraph, node) &&
313 "FSMPTA worklist must never contain a node outside the solve graph");
314
315 if (processSVFGNode(node))
316 {
317 if constexpr (SolveGraphTraits::isFilteredGraph)
318 {
319 const auto found = retainedOutEdges.find(nodeId);
320 if (found != retainedOutEdges.end())
321 {
322 for (SVFGEdge* edge : found->second)
323 {
325 {
326 pushIntoWorklist(edge->getDstID());
327 }
328 }
329 }
330 }
331 else
332 {
333 for (SVFGEdge* edge : node->getOutEdges())
334 {
336 {
337 pushIntoWorklist(edge->getDstID());
338 }
339 }
340 }
341 }
343}
bool propFromSrcToDst(SVFGEdge *edge) override
Propagation.
void clearAllDFOutVarFlag(const SVFGNode *stmt)
bool processSVFGNode(SVFGNode *node)
SVFGNode * getSVFGNode(NodeID id) const
Get a SVFG node.
Definition SVFG.h:150
virtual void pushIntoWorklist(NodeID id)
Definition WPASolver.h:157

◆ SCCDetect()

template<class SVFGGraph >
NodeStack & FSMPTA::SCCDetect ( )
overrideprotectedvirtual

SCC detection.

SCC detection

Reimplemented from SVF::FlowSensitive.

Definition at line 284 of file FSMPTA.cpp.

285{
286 const double start = stat->getClk();
287 solveSCC->find();
288 assert(solveNodeStack.empty() && "FSMPTA SCC stack was not fully consumed");
289
290 FIFOWorkList<NodeID> revTopo = solveSCC->revTopoNodeStack();
291 while (!revTopo.empty())
292 {
293 const NodeID rep = revTopo.front();
294 revTopo.pop();
295 const NodeBS& subNodes = solveSCC->subNodes(rep);
296 for (NodeID id : subNodes)
297 solveNodeStack.push(id);
298 }
299
300 assert(solveNodeStack.size() == SolveGraphTraits::graphSize(solveGraph) &&
301 "FSMPTA SCC topology must contain exactly the solve graph");
302
303 const double end = stat->getClk();
304 sccTime += (end - start) / TIMEINTERVAL;
305 return solveNodeStack;
306}
#define TIMEINTERVAL
Definition SVFType.h:604
NodeStack solveNodeStack
Definition FSMPTA.h:97
double sccTime
time of SCC detection.
static double getClk(bool mark=false)
Definition SVFStat.cpp:51

◆ supportsCurrentConfiguration()

template<class SVFGGraph >
bool FSMPTA::supportsCurrentConfiguration ( )
static

Definition at line 50 of file FSMPTA.cpp.

51{
54}
static const Option< bool > PlainMappingFs
Use an explicitly plain mapping with flow-sensitive (not null).
Definition Options.h:43
static const Option< bool > ClusterAnder
Whether to stage Andersen's with Steensgaard and cluster based on that data.
Definition Options.h:37
static const Option< bool > ClusterFs
Whether to cluster FS or VFS with the auxiliary Andersen's.
Definition Options.h:40

◆ updateConnectedNodes()

template<class SVFGGraph >
void FSMPTA::updateConnectedNodes ( const SVFGEdgeSetTy edges)
overrideprotectedvirtual

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

Definition at line 346 of file FSMPTA.cpp.

347{
348 if constexpr (SolveGraphTraits::isFilteredGraph)
349 {
350 SVFGEdgeSetTy keptEdges;
351 for (SVFGEdge* edge : edges)
352 if (SolveGraphTraits::containsEdge(solveGraph, edge))
353 {
354 keptEdges.insert(edge);
356 }
358 }
359 else
360 {
362 }
363}
if(prebuffer< 0)
Definition cJSON.cpp:1269
GenericGraphTraits< SVFGGraph > SolveGraphTraits
Definition FSMPTA.h:80
virtual void updateConnectedNodes(const SVFGEdgeSetTy &edges)
Update nodes connected during updating call graph.
SVFG::SVFGEdgeSetTy SVFGEdgeSetTy

Member Data Documentation

◆ backingGraph

template<class SVFGGraph >
SVFG* SVF::FSMPTA< SVFGGraph >::backingGraph
private

Definition at line 94 of file FSMPTA.h.

◆ preAnalysis

template<class SVFGGraph >
AndersenWaveDiff* SVF::FSMPTA< SVFGGraph >::preAnalysis
private

Definition at line 93 of file FSMPTA.h.

◆ retainedEdgeSet

template<class SVFGGraph >
Set<const SVFGEdge*> SVF::FSMPTA< SVFGGraph >::retainedEdgeSet
private

Definition at line 99 of file FSMPTA.h.

◆ retainedOutEdges

template<class SVFGGraph >
Map<NodeID, std::vector<SVFGEdge*> > SVF::FSMPTA< SVFGGraph >::retainedOutEdges
private

Definition at line 98 of file FSMPTA.h.

◆ solveGraph

template<class SVFGGraph >
SVFGGraph SVF::FSMPTA< SVFGGraph >::solveGraph
private

Definition at line 95 of file FSMPTA.h.

◆ solveNodeStack

template<class SVFGGraph >
NodeStack SVF::FSMPTA< SVFGGraph >::solveNodeStack
private

Definition at line 97 of file FSMPTA.h.

◆ solveSCC

template<class SVFGGraph >
std::unique_ptr<SCCDetection<SVFGGraph> > SVF::FSMPTA< SVFGGraph >::solveSCC
private

Definition at line 96 of file FSMPTA.h.


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