SVF
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SVF::AndersenWaveDiffWithType Class Reference

#include <Andersen.h>

Inheritance diagram for SVF::AndersenWaveDiffWithType:
SVF::AndersenWaveDiff SVF::Andersen SVF::AndersenBase SVF::WPASolver< GraphType > SVF::BVDataPTAImpl SVF::PointerAnalysis

Public Member Functions

 AndersenWaveDiffWithType (PAG *_pag, PTATY type=AndersenWaveDiffWithType_WPA)
 
- Public Member Functions inherited from SVF::AndersenWaveDiff
 AndersenWaveDiff (PAG *_pag, PTATY type=AndersenWaveDiff_WPA, bool alias_check=true)
 
virtual void solveWorklist ()
 
virtual void processNode (NodeID nodeId)
 
virtual void postProcessNode (NodeID nodeId)
 
virtual void handleCopyGep (ConstraintNode *node)
 
virtual bool handleLoad (NodeID id, const ConstraintEdge *load)
 
virtual bool handleStore (NodeID id, const ConstraintEdge *store)
 
virtual bool processCopy (NodeID node, const ConstraintEdge *edge)
 
- Public Member Functions inherited from SVF::Andersen
 Andersen (PAG *_pag, PTATY type=Andersen_WPA, bool alias_check=true)
 Constructor. More...
 
virtual ~Andersen ()
 Destructor. More...
 
virtual void initialize ()
 Initialize analysis. More...
 
virtual void finalize ()
 Finalize analysis. More...
 
void resetData ()
 Reset data. More...
 
virtual const PointsTogetPts (NodeID id)
 Operation of points-to set. More...
 
virtual bool unionPts (NodeID id, const PointsTo &target)
 
virtual bool unionPts (NodeID id, NodeID ptd)
 
void dumpTopLevelPtsTo ()
 
void setPWCOpt (bool flag)
 
bool mergePWC () const
 
void setDiffOpt (bool flag)
 
bool enableDiff () const
 
NodeID sccRepNode (NodeID id) const
 SCC methods. More...
 
NodeBSsccSubNodes (NodeID repId)
 
- Public Member Functions inherited from SVF::AndersenBase
 AndersenBase (PAG *_pag, PTATY type=Andersen_BASE, bool alias_check=true)
 Constructor. More...
 
virtual ~AndersenBase ()
 Destructor. More...
 
virtual void analyze () override
 Andersen analysis. More...
 
ConstraintGraphgetConstraintGraph ()
 Get constraint graph. More...
 
void printStat ()
 dump statistics More...
 
virtual void normalizePointsTo () override
 
void cleanConsCG (NodeID id)
 remove redundant gepnodes in constraint graph More...
 
- Public Member Functions inherited from SVF::BVDataPTAImpl
 BVDataPTAImpl (PAG *pag, PointerAnalysis::PTATY type, bool alias_check=true)
 Constructor. More...
 
virtual ~BVDataPTAImpl ()
 Destructor. More...
 
void destroy ()
 Release memory. More...
 
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 void clearAllPts ()
 Clear all data. More...
 
virtual void expandFIObjs (const PointsTo &pts, PointsTo &expandedPts)
 Expand FI objects. More...
 
virtual AliasResult alias (const MemoryLocation &LocA, const MemoryLocation &LocB)
 Interface expose to users of our pointer analysis, given Location infos. More...
 
virtual AliasResult alias (const Value *V1, const Value *V2)
 Interface expose to users of our pointer analysis, given Value infos. More...
 
virtual AliasResult alias (NodeID node1, NodeID node2)
 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...
 
virtual const NodeBSgetRevPts (NodeID nodeId)
 
virtual bool addPts (NodeID id, NodeID ptd)
 
virtual void writeToFile (const std::string &filename)
 Interface for analysis result storage on filesystem. More...
 
virtual bool readFromFile (const std::string &filename)
 
virtual void dumpCPts ()
 dump and debug, print out conditional pts More...
 
virtual void dumpAllPts ()
 
- Public Member Functions inherited from SVF::PointerAnalysis
Size_t getNumOfResolvedIndCallEdge () const
 Return number of resolved indirect call edges. More...
 
PTACallGraphgetPTACallGraph () const
 Return call graph. More...
 
CallGraphSCCgetCallGraphSCC () const
 Return call graph SCC. More...
 
 PointerAnalysis (PAG *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...
 
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...
 
virtual void clearPts ()
 Clear points-to data. More...
 
void printIndCSTargets (const CallBlockNode *cs, const FunctionSet &targets)
 Print targets of a function pointer. More...
 
void dumpStat ()
 Dump the statistics. More...
 
bool printStat ()
 Whether print statistics. More...
 
void disablePrintStat ()
 Whether print statistics. More...
 
virtual void resolveIndCalls (const CallBlockNode *cs, const PointsTo &target, CallEdgeMap &newEdges, LLVMCallGraph *callgraph=nullptr)
 Resolve indirect call edges. More...
 
bool matchArgs (const CallBlockNode *cs, const SVFFunction *callee)
 Match arguments for callsite at caller and callee. More...
 
CommonCHGraphgetCHGraph () const
 get CHGraph More...
 
void getVFnsFromCHA (const CallBlockNode *cs, VFunSet &vfns)
 
void getVFnsFromPts (const CallBlockNode *cs, const PointsTo &target, VFunSet &vfns)
 
void connectVCallToVFns (const CallBlockNode *cs, const VFunSet &vfns, CallEdgeMap &newEdges)
 
virtual void resolveCPPIndCalls (const CallBlockNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
 Resolve cpp indirect call edges. More...
 
const TypeSystemgetTypeSystem () const
 get TypeSystem More...
 
PAGgetPAG () const
 
virtual void dumpPts (NodeID ptr, const PointsTo &pts)
 
void printIndCSTargets ()
 
void dumpAllTypes ()
 
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 isNonPointerObj (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 getBaseObjNode (NodeID id)
 
NodeID getFIObjNode (NodeID id)
 
NodeID getGepObjNode (NodeID id, const LocationSet &ls)
 
virtual const NodeBSgetAllFieldsObjNode (NodeID id)
 
void setObjFieldInsensitive (NodeID id)
 
bool isFieldInsensitive (NodeID id) const
 
CallEdgeMapgetIndCallMap ()
 Get callees from an indirect callsite. More...
 
bool hasIndCSCallees (const CallBlockNode *cs) const
 
const FunctionSetgetIndCSCallees (const CallBlockNode *cs) const
 
void callGraphSCCDetection ()
 CallGraph 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 CallGraph 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...
 

Static Public Member Functions

static AndersenWaveDiffWithTypecreateAndersenWaveDiffWithType (PAG *p)
 Create an singleton instance directly instead of invoking llvm pass manager. More...
 
static void releaseAndersenWaveDiffWithType ()
 
- Static Public Member Functions inherited from SVF::AndersenWaveDiff
static AndersenWaveDiffcreateAndersenWaveDiff (PAG *_pag)
 Create an singleton instance directly instead of invoking llvm pass manager. More...
 
static void releaseAndersenWaveDiff ()
 
- Static Public Member Functions inherited from SVF::Andersen
static bool classof (const Andersen *)
 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::AndersenBase
static bool classof (const AndersenBase *)
 Methods for support type inquiry through isa, cast, and dyn_cast: More...
 
static bool classof (const PointerAnalysis *pta)
 
- Static Public Member Functions inherited from SVF::BVDataPTAImpl
static bool classof (const PointerAnalysis *pta)
 

Protected Member Functions

virtual NodeStackSCCDetect ()
 SCC detection. More...
 
void mergeTypeOfNodes (const NodeBS &nodes)
 merge types of nodes in a cycle More...
 
virtual void processCast (const ConstraintEdge *edge)
 process "bitcast" CopyCGEdge More...
 
void updateObjType (const Type *type, const PointsTo &objs)
 update type of objects when process "bitcast" CopyCGEdge More...
 
void processTypeMismatchedGep (NodeID obj, const Type *type)
 process mismatched gep edges More...
 
virtual bool matchType (NodeID ptrid, NodeID objid, const NormalGepCGEdge *normalGepEdge)
 match types for Gep Edges More...
 
virtual void addTypeForGepObjNode (NodeID id, const NormalGepCGEdge *normalGepEdge)
 add type for newly created GepObjNode More...
 
- Protected Member Functions inherited from SVF::AndersenWaveDiff
virtual void mergeNodeToRep (NodeID nodeId, NodeID newRepId)
 Merge sub node to its rep. More...
 
- Protected Member Functions inherited from SVF::Andersen
void heapAllocatorViaIndCall (CallSite cs, NodePairSet &cpySrcNodes)
 
void updatePropaPts (NodeID dstId, NodeID srcId)
 Handle propagated points-to set. More...
 
void clearPropaPts (NodeID src)
 
virtual void initWorklist ()
 
virtual void setSCCEdgeFlag (ConstraintNode::SCCEdgeFlag f)
 
virtual bool addCopyEdge (NodeID src, NodeID dst)
 Add copy edge on constraint graph. More...
 
virtual bool updateCallGraph (const CallSiteToFunPtrMap &callsites)
 Update call graph for the input indirect callsites. More...
 
void connectCaller2CalleeParams (CallSite cs, const SVFFunction *F, NodePairSet &cpySrcNodes)
 Connect formal and actual parameters for indirect callsites. More...
 
virtual bool mergeSrcToTgt (NodeID srcId, NodeID tgtId)
 
void updateNodeRepAndSubs (NodeID nodeId, NodeID newRepId)
 Updates subnodes of its rep, and rep node of its subs. More...
 
void sanitizePts ()
 Sanitize pts for field insensitive objects. More...
 
virtual const std::string PTAName () const
 Get PTA name. More...
 
void processAllAddr ()
 handling various constraints More...
 
virtual bool processLoad (NodeID node, const ConstraintEdge *load)
 
virtual bool processStore (NodeID node, const ConstraintEdge *load)
 
virtual bool processGep (NodeID node, const GepCGEdge *edge)
 
virtual void handleLoadStore (ConstraintNode *node)
 
virtual void processAddr (const AddrCGEdge *addr)
 
virtual bool processGepPts (const PointsTo &pts, const GepCGEdge *edge)
 
void mergeSccNodes (NodeID repNodeId, const NodeBS &subNodes)
 Merge sub node in a SCC cycle to their rep node. More...
 
void mergeSccCycle ()
 
void collapsePWCNode (NodeID nodeId)
 Collapse a field object into its base for field insensitive anlaysis. More...
 
void collapseFields ()
 
bool collapseNodePts (NodeID nodeId)
 
bool collapseField (NodeID nodeId)
 
- Protected Member Functions inherited from SVF::WPASolver< GraphType >
 WPASolver ()
 Constructor. More...
 
virtual ~WPASolver ()
 Destructor. More...
 
SCCgetSCCDetector () const
 Get SCC detector. More...
 
virtual NodeStackSCCDetect (NodeSet &candidates)
 
GNODENode (NodeID id)
 Get node on the graph. More...
 
NodeID Node_Index (GNODE node)
 Get node ID. More...
 
const GraphType graph ()
 Get/Set graph methods. More...
 
void setGraph (GraphType g)
 
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)
 
- 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...
 
- Protected Member Functions inherited from SVF::PointerAnalysis
const CallSiteToFunPtrMapgetIndirectCallsites () const
 Return all indirect callsites. More...
 
NodeID getFunPtr (const CallBlockNode *cs) const
 Return function pointer PAGNode at a callsite cs. More...
 
bool dumpGraph ()
 Whether to dump the graph for debugging purpose. More...
 
void resetObjFieldSensitive ()
 Reset all object node as field-sensitive. 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)
 

Private Types

typedef Map< NodeID, Set< const GepCGEdge * > > TypeMismatchedObjToEdgeTy
 

Private Member Functions

void recordTypeMismatchedGep (NodeID obj, const GepCGEdge *gepEdge)
 
virtual void computeDiffPts (NodeID id)
 Handle diff points-to set. More...
 
virtual const PointsTogetDiffPts (NodeID id)
 

Private Attributes

TypeMismatchedObjToEdgeTy typeMismatchedObjToEdges
 

Static Private Attributes

static AndersenWaveDiffWithTypediffWaveWithType = nullptr
 

Additional Inherited Members

- Public Types inherited from SVF::Andersen
typedef SCCDetection< ConstraintGraph * > CGSCC
 
typedef OrderedMap< CallSite, NodeIDCallSite2DummyValPN
 
- Public Types inherited from SVF::WPASolver< GraphType >
typedef llvm::GraphTraits< 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
typedef PTData< NodeID, NodeBS, NodeID, PointsToPTDataTy
 
typedef MutablePTData< NodeID, NodeBS, NodeID, PointsToMutPTDataTy
 
typedef DiffPTData< NodeID, NodeBS, NodeID, PointsToDiffPTDataTy
 
typedef MutableDiffPTData< NodeID, NodeBS, NodeID, PointsToMutDiffPTDataTy
 
typedef DFPTData< NodeID, NodeBS, NodeID, PointsToDFPTDataTy
 
typedef MutableDFPTData< NodeID, NodeBS, NodeID, PointsToMutDFPTDataTy
 
typedef IncMutableDFPTData< NodeID, NodeBS, NodeID, PointsToIncMutDFPTDataTy
 
typedef VersionedPTData< NodeID, NodeBS, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > VersionedPTDataTy
 
typedef MutableVersionedPTData< NodeID, NodeBS, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > MutVersionedPTDataTy
 
- Public Types inherited from SVF::PointerAnalysis
enum  PTATY {
  Andersen_BASE, Andersen_WPA, AndersenLCD_WPA, AndersenHCD_WPA,
  AndersenHLCD_WPA, AndersenSCD_WPA, AndersenSFR_WPA, AndersenWaveDiff_WPA,
  AndersenWaveDiffWithType_WPA, Steensgaard_WPA, CSCallString_WPA, CSSummary_WPA,
  FSDATAFLOW_WPA, FSSPARSE_WPA, FSTBHC_WPA, VFS_WPA,
  FSCS_WPA, FSCSPS_WPA, ADAPTFSCS_WPA, ADAPTFSCSPS_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 llvm::AliasAnalysis AliasAnalysis
 Indirect call edges type, map a callsite to a set of callees. More...
 
typedef Set< const CallBlockNode * > CallSiteSet
 
typedef PAG::CallSiteToFunPtrMap CallSiteToFunPtrMap
 
typedef Set< const SVFFunction * > FunctionSet
 
typedef OrderedMap< const CallBlockNode *, FunctionSetCallEdgeMap
 
typedef SCCDetection< PTACallGraph * > CallGraphSCC
 
typedef Set< const GlobalValue * > VTableSet
 
typedef Set< const SVFFunction * > VFunSet
 
- Public Attributes inherited from SVF::AndersenBase
NodeBS redundantGepNodes
 
- Public Attributes inherited from SVF::WPASolver< GraphType >
u32_t numOfIteration
 num of iterations during constaint solving More...
 
- Static Public Attributes inherited from SVF::AndersenBase
static Size_t numOfProcessedAddr = 0
 Statistics. More...
 
static Size_t numOfProcessedCopy = 0
 Number of processed Addr edge. More...
 
static Size_t numOfProcessedGep = 0
 Number of processed Copy edge. More...
 
static Size_t numOfProcessedLoad = 0
 Number of processed Gep edge. More...
 
static Size_t numOfProcessedStore = 0
 Number of processed Load edge. More...
 
static Size_t numOfSfrs = 0
 Number of processed Store edge. More...
 
static Size_t numOfFieldExpand = 0
 
static Size_t numOfSCCDetection = 0
 
static double timeOfSCCDetection = 0
 
static double timeOfSCCMerges = 0
 
static double timeOfCollapse = 0
 
static Size_t AveragePointsToSetSize = 0
 
static Size_t MaxPointsToSetSize = 0
 
static double timeOfProcessCopyGep = 0
 
static double timeOfProcessLoadStore = 0
 
static double timeOfUpdateCallGraph = 0
 
- Static Public Attributes inherited from SVF::PointerAnalysis
static const std::string aliasTestMayAlias = "MAYALIAS"
 
static const std::string aliasTestMayAliasMangled = "_Z8MAYALIASPvS_"
 
static const std::string aliasTestNoAlias = "NOALIAS"
 
static const std::string aliasTestNoAliasMangled = "_Z7NOALIASPvS_"
 
static const std::string aliasTestPartialAlias = "PARTIALALIAS"
 
static const std::string aliasTestPartialAliasMangled = "_Z12PARTIALALIASPvS_"
 
static const std::string aliasTestMustAlias = "MUSTALIAS"
 
static const std::string aliasTestMustAliasMangled = "_Z9MUSTALIASPvS_"
 
static const std::string aliasTestFailMayAlias = "EXPECTEDFAIL_MAYALIAS"
 
static const std::string aliasTestFailMayAliasMangled = "_Z21EXPECTEDFAIL_MAYALIASPvS_"
 
static const std::string aliasTestFailNoAlias = "EXPECTEDFAIL_NOALIAS"
 
static const std::string aliasTestFailNoAliasMangled = "_Z20EXPECTEDFAIL_NOALIASPvS_"
 
- Protected Attributes inherited from SVF::Andersen
CallSite2DummyValPN callsite2DummyValPN
 Map an instruction to a dummy obj which created at an indirect callsite, which invokes a heap allocator. More...
 
bool pwcOpt
 
bool diffOpt
 
- Protected Attributes inherited from SVF::AndersenBase
ConstraintGraphconsCG
 Constraint Graph. 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...
 
SCCscc
 SCC. More...
 
WorkList worklist
 Worklist for resolution. More...
 
- Protected Attributes inherited from SVF::PointerAnalysis
SVFModulesvfMod
 Module. More...
 
PTATY ptaTy
 Pointer analysis Type. More...
 
PTAImplTy ptaImplTy
 PTA implementation type. More...
 
PTAStatstat
 Statistics. More...
 
PTACallGraphptaCallGraph
 Call graph used for pointer analysis. More...
 
CallGraphSCCcallGraphSCC
 SCC for CallGraph. More...
 
ICFGicfg
 Interprocedural control-flow graph. More...
 
TypeSystemtypeSystem
 TypeSystem. More...
 
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...
 
- Static Protected Attributes inherited from SVF::PointerAnalysis
static PAGpag = nullptr
 PAG. More...
 
static CommonCHGraphchgraph = nullptr
 CHGraph. More...
 

Detailed Description

Wave propagation with diff points-to set with type filter.

Definition at line 469 of file Andersen.h.

Member Typedef Documentation

◆ TypeMismatchedObjToEdgeTy

Definition at line 474 of file Andersen.h.

Constructor & Destructor Documentation

◆ AndersenWaveDiffWithType()

SVF::AndersenWaveDiffWithType::AndersenWaveDiffWithType ( PAG _pag,
PTATY  type = AndersenWaveDiffWithType_WPA 
)
inline

Definition at line 511 of file Andersen.h.

511  : AndersenWaveDiff(_pag,type)
512  {
513  assert(getTypeSystem()!=nullptr && "a type system is required for this pointer analysis");
514  }
#define assert(ex)
Definition: util.h:141
AndersenWaveDiff(PAG *_pag, PTATY type=AndersenWaveDiff_WPA, bool alias_check=true)
Definition: Andersen.h:426
const TypeSystem * getTypeSystem() const
get TypeSystem

Member Function Documentation

◆ addTypeForGepObjNode()

void AndersenWaveDiffWithType::addTypeForGepObjNode ( NodeID  id,
const NormalGepCGEdge normalGepEdge 
)
protectedvirtual

add type for newly created GepObjNode

Reimplemented from SVF::Andersen.

Definition at line 96 of file AndersenWaveDiffWithType.cpp.

97 {
98  NodeID srcId = normalGepEdge->getSrcID();
99  NodeID dstId = normalGepEdge->getDstID();
101  {
102  const Value *val = pag->getIntraPAGEdge(srcId, dstId, PAGEdge::NormalGep)->getValue();
103  if (val)
104  {
105  PTAType ptaTy(val->getType());
106  if(typeSystem->addTypeForVar(id, ptaTy))
108  }
109  }
110 }
bool addTypeForVar(NodeID var, const PTAType &type)
Definition: PTAType.h:243
const Value * getValue() const
Definition: PAGEdge.h:116
NodeID getDstID() const
Definition: GenericGraph.h:77
u32_t NodeID
Definition: SVFBasicTypes.h:80
NodeID getSrcID() const
get methods of the components
Definition: GenericGraph.h:73
TypeSystem * typeSystem
TypeSystem.
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PTATY ptaTy
Pointer analysis Type.
void addVarForType(NodeID var, const PTAType &type)
Definition: PTAType.h:268
PAGEdge * getIntraPAGEdge(NodeID src, NodeID dst, PAGEdge::PEDGEK kind)
Get an edge according to src, dst and kind.
Definition: PAG.h:498
PAGEdge * hasNonlabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind)
Definition: PAG.cpp:725
llvm::Value Value
Definition: BasicTypes.h:78
static PAG * pag
PAG.

◆ computeDiffPts()

virtual void SVF::AndersenWaveDiffWithType::computeDiffPts ( NodeID  id)
inlineprivatevirtual

Handle diff points-to set.

Reimplemented from SVF::Andersen.

Definition at line 498 of file Andersen.h.

499  {
500  NodeID rep = sccRepNode(id);
502  }
virtual const PointsTo & getPts(NodeID id)
Operation of points-to set.
Definition: Andersen.h:222
virtual bool computeDiffPts(Key &var, const DataSet &all)=0
u32_t NodeID
Definition: SVFBasicTypes.h:80
DiffPTDataTy * getDiffPTDataTy() const
NodeID sccRepNode(NodeID id) const
SCC methods.
Definition: Andersen.h:211

◆ createAndersenWaveDiffWithType()

static AndersenWaveDiffWithType* SVF::AndersenWaveDiffWithType::createAndersenWaveDiffWithType ( PAG p)
inlinestatic

Create an singleton instance directly instead of invoking llvm pass manager.

Definition at line 517 of file Andersen.h.

518  {
519  if(diffWaveWithType==nullptr)
520  {
523  return diffWaveWithType;
524  }
525  return diffWaveWithType;
526  }
virtual void analyze() override
Andersen analysis.
Definition: Andersen.cpp:92
AndersenWaveDiffWithType(PAG *_pag, PTATY type=AndersenWaveDiffWithType_WPA)
Definition: Andersen.h:511
static AndersenWaveDiffWithType * diffWaveWithType
Definition: Andersen.h:494

◆ getDiffPts()

virtual const PointsTo& SVF::AndersenWaveDiffWithType::getDiffPts ( NodeID  id)
inlineprivatevirtual

Reimplemented from SVF::Andersen.

Definition at line 503 of file Andersen.h.

504  {
505  NodeID rep = sccRepNode(id);
506  return getDiffPTDataTy()->getDiffPts(rep);
507  }
u32_t NodeID
Definition: SVFBasicTypes.h:80
virtual const DataSet & getDiffPts(Key &var)=0
Get diff points to.
DiffPTDataTy * getDiffPTDataTy() const
NodeID sccRepNode(NodeID id) const
SCC methods.
Definition: Andersen.h:211

◆ matchType()

bool AndersenWaveDiffWithType::matchType ( NodeID  ptrid,
NodeID  objid,
const NormalGepCGEdge normalGepEdge 
)
protectedvirtual

match types for Gep Edges

Reimplemented from SVF::Andersen.

Definition at line 78 of file AndersenWaveDiffWithType.cpp.

79 {
80  if (!typeSystem->hasTypeSet(ptrid) || !typeSystem->hasTypeSet(objid))
81  return true;
82  const TypeSet *ptrTypeSet = typeSystem->getTypeSet(ptrid);
83  const TypeSet *objTypeSet = typeSystem->getTypeSet(objid);
84  if (ptrTypeSet->intersect(objTypeSet))
85  {
86  return true;
87  }
88  else
89  {
90  recordTypeMismatchedGep(objid, normalGepEdge);
91  return false;
92  }
93 }
void recordTypeMismatchedGep(NodeID obj, const GepCGEdge *gepEdge)
Definition: Andersen.h:478
TypeSystem * typeSystem
TypeSystem.
bool intersect(const TypeSet *typeset) const
Intersect with another typeset or not.
Definition: PTAType.h:140
const TypeSet * getTypeSet(NodeID var) const
Get a var&#39;s typeset.
Definition: PTAType.h:234
bool hasTypeSet(NodeID var) const
Has typeset or not.
Definition: PTAType.h:227

◆ mergeTypeOfNodes()

void AndersenWaveDiffWithType::mergeTypeOfNodes ( const NodeBS nodes)
protected

merge types of nodes in a cycle

collect types in a cycle

merge types of nodes in a cycle

Definition at line 128 of file AndersenWaveDiffWithType.cpp.

129 {
130 
132  OrderedSet<PTAType> typesInSCC;
133  for (NodeBS::iterator it = nodes.begin(), eit = nodes.end(); it != eit; ++it)
134  {
135  if (typeSystem->hasTypeSet(*it))
136  {
137  const TypeSet *typeSet = typeSystem->getTypeSet(*it);
138  for (TypeSet::const_iterator tyit = typeSet->begin(), tyeit = typeSet->end(); tyit != tyeit; ++tyit)
139  {
140  const PTAType &ptaTy = *tyit;
141  typesInSCC.insert(ptaTy);
142  }
143  }
144  }
145 
147  for (NodeBS::iterator it = nodes.begin(), eit = nodes.end(); it != eit; ++it)
148  {
149  for (OrderedSet<PTAType>::iterator tyit = typesInSCC.begin(), tyeit = typesInSCC.end(); tyit != tyeit; ++tyit)
150  {
151  const PTAType &ptaTy = *tyit;
152  if (typeSystem->addTypeForVar(*it, ptaTy))
153  typeSystem->addVarForType(*it, ptaTy);
154  }
155  }
156 
157 }
bool addTypeForVar(NodeID var, const PTAType &type)
Definition: PTAType.h:243
std::set< Key, Compare, Allocator > OrderedSet
TypeSystem * typeSystem
TypeSystem.
PTATY ptaTy
Pointer analysis Type.
void addVarForType(NodeID var, const PTAType &type)
Definition: PTAType.h:268
iterator begin()
Definition: PTAType.h:99
TypeSetTy::const_iterator const_iterator
Definition: PTAType.h:95
const TypeSet * getTypeSet(NodeID var) const
Get a var&#39;s typeset.
Definition: PTAType.h:234
bool hasTypeSet(NodeID var) const
Has typeset or not.
Definition: PTAType.h:227
iterator end()
Definition: PTAType.h:103

◆ processCast()

void AndersenWaveDiffWithType::processCast ( const ConstraintEdge edge)
protectedvirtual

process "bitcast" CopyCGEdge

Reimplemented from SVF::AndersenWaveDiff.

Definition at line 11 of file AndersenWaveDiffWithType.cpp.

12 {
13  NodeID srcId = edge->getSrcID();
14  NodeID dstId = edge->getDstID();
16  {
17  const Value *val = pag->getIntraPAGEdge(srcId, dstId, PAGEdge::Copy)->getValue();
18  if (val)
19  {
20  if (const CastInst *castInst = SVFUtil::dyn_cast<CastInst>(val))
21  {
22  updateObjType(castInst->getType(), getPts(edge->getSrcID()));
23  }
24  else if (const ConstantExpr *ce = SVFUtil::dyn_cast<ConstantExpr>(val))
25  {
26  if (ce->getOpcode() == Instruction::BitCast)
27  {
28  updateObjType(ce->getType(), getPts(edge->getSrcID()));
29  }
30  }
31  }
32  }
33 }
virtual const PointsTo & getPts(NodeID id)
Operation of points-to set.
Definition: Andersen.h:222
const Value * getValue() const
Definition: PAGEdge.h:116
llvm::CastInst CastInst
Definition: BasicTypes.h:150
NodeID getDstID() const
Definition: GenericGraph.h:77
u32_t NodeID
Definition: SVFBasicTypes.h:80
NodeID getSrcID() const
get methods of the components
Definition: GenericGraph.h:73
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * getIntraPAGEdge(NodeID src, NodeID dst, PAGEdge::PEDGEK kind)
Get an edge according to src, dst and kind.
Definition: PAG.h:498
void updateObjType(const Type *type, const PointsTo &objs)
update type of objects when process "bitcast" CopyCGEdge
llvm::ConstantExpr ConstantExpr
Definition: BasicTypes.h:125
PAGEdge * hasNonlabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind)
Definition: PAG.cpp:725
llvm::Value Value
Definition: BasicTypes.h:78
static PAG * pag
PAG.

◆ processTypeMismatchedGep()

void AndersenWaveDiffWithType::processTypeMismatchedGep ( NodeID  obj,
const Type type 
)
protected

process mismatched gep edges

Definition at line 49 of file AndersenWaveDiffWithType.cpp.

50 {
51  TypeMismatchedObjToEdgeTy::iterator it = typeMismatchedObjToEdges.find(obj);
52  if (it == typeMismatchedObjToEdges.end())
53  return;
54  Set<const GepCGEdge*> &edges = it->second;
55  Set<const GepCGEdge*> processed;
56 
57  PTAType ptaTy(type);
58  NodeBS &nodesOfType = typeSystem->getVarsForType(ptaTy);
59 
60  for (Set<const GepCGEdge*>::iterator nit = edges.begin(), neit = edges.end(); nit != neit; ++nit)
61  {
62  if (const NormalGepCGEdge *normalGepEdge = SVFUtil::dyn_cast<NormalGepCGEdge>(*nit))
63  {
64  if (!nodesOfType.test(normalGepEdge->getSrcID()))
65  continue;
66  PointsTo tmpPts;
67  tmpPts.set(obj);
68  Andersen::processGepPts(tmpPts, normalGepEdge);
69  processed.insert(normalGepEdge);
70  }
71  }
72 
73  for (Set<const GepCGEdge*>::iterator nit = processed.begin(), neit = processed.end(); nit != neit; ++nit)
74  edges.erase(*nit);
75 }
TypeMismatchedObjToEdgeTy typeMismatchedObjToEdges
Definition: Andersen.h:476
TypeSystem * typeSystem
TypeSystem.
PTATY ptaTy
Pointer analysis Type.
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition: SVFBasicTypes.h:93
virtual bool processGepPts(const PointsTo &pts, const GepCGEdge *edge)
Definition: Andersen.cpp:358
llvm::SparseBitVector NodeBS
Definition: SVFBasicTypes.h:87
NodeBS PointsTo
Definition: SVFBasicTypes.h:88
NodeBS & getVarsForType(const PTAType &type)
Definition: PTAType.h:296

◆ recordTypeMismatchedGep()

void SVF::AndersenWaveDiffWithType::recordTypeMismatchedGep ( NodeID  obj,
const GepCGEdge gepEdge 
)
inlineprivate

Definition at line 478 of file Andersen.h.

479  {
480  TypeMismatchedObjToEdgeTy::iterator it = typeMismatchedObjToEdges.find(obj);
481  if (it != typeMismatchedObjToEdges.end())
482  {
483  Set<const GepCGEdge*> &edges = it->second;
484  edges.insert(gepEdge);
485  }
486  else
487  {
488  Set<const GepCGEdge*> edges;
489  edges.insert(gepEdge);
490  typeMismatchedObjToEdges[obj] = edges;
491  }
492  }
TypeMismatchedObjToEdgeTy typeMismatchedObjToEdges
Definition: Andersen.h:476

◆ releaseAndersenWaveDiffWithType()

static void SVF::AndersenWaveDiffWithType::releaseAndersenWaveDiffWithType ( )
inlinestatic

Definition at line 527 of file Andersen.h.

528  {
529  if (diffWaveWithType)
530  delete diffWaveWithType;
531  diffWaveWithType = nullptr;
532  }
static AndersenWaveDiffWithType * diffWaveWithType
Definition: Andersen.h:494

◆ SCCDetect()

NodeStack & AndersenWaveDiffWithType::SCCDetect ( )
protectedvirtual

SCC detection.

merge types of nodes in SCC

Reimplemented from SVF::Andersen.

Definition at line 112 of file AndersenWaveDiffWithType.cpp.

113 {
115 
117  const NodeBS &repNodes = getSCCDetector()->getRepNodes();
118  for (NodeBS::iterator it = repNodes.begin(), eit = repNodes.end(); it != eit; ++it)
119  {
120  NodeBS subNodes = getSCCDetector()->subNodes(*it);
121  mergeTypeOfNodes(subNodes);
122  }
123 
124  return getSCCDetector()->topoNodeStack();
125 }
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
GNodeStack & topoNodeStack()
Definition: SCC.h:128
const NodeBS & getRepNodes() const
get all repNodeID
Definition: SCC.h:181
SCC * getSCCDetector() const
Get SCC detector.
Definition: WPASolver.h:71
llvm::SparseBitVector NodeBS
Definition: SVFBasicTypes.h:87
virtual NodeStack & SCCDetect()
SCC detection.
Definition: Andersen.cpp:571
void mergeTypeOfNodes(const NodeBS &nodes)
merge types of nodes in a cycle

◆ updateObjType()

void AndersenWaveDiffWithType::updateObjType ( const Type type,
const PointsTo objs 
)
protected

update type of objects when process "bitcast" CopyCGEdge

Definition at line 36 of file AndersenWaveDiffWithType.cpp.

37 {
38  for (PointsTo::iterator it = objs.begin(), eit = objs.end(); it != eit; ++it)
39  {
40  if (typeSystem->addTypeForVar(*it, type))
41  {
42  typeSystem->addVarForType(*it, type);
43  processTypeMismatchedGep(*it, type);
44  }
45  }
46 }
bool addTypeForVar(NodeID var, const PTAType &type)
Definition: PTAType.h:243
TypeSystem * typeSystem
TypeSystem.
void addVarForType(NodeID var, const PTAType &type)
Definition: PTAType.h:268
void processTypeMismatchedGep(NodeID obj, const Type *type)
process mismatched gep edges

Member Data Documentation

◆ diffWaveWithType

AndersenWaveDiffWithType * AndersenWaveDiffWithType::diffWaveWithType = nullptr
staticprivate

Definition at line 494 of file Andersen.h.

◆ typeMismatchedObjToEdges

TypeMismatchedObjToEdgeTy SVF::AndersenWaveDiffWithType::typeMismatchedObjToEdges
private

Definition at line 476 of file Andersen.h.


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