38using namespace SVFUtil;
187 assert(!
consCG->
hasGNode(
id) &&
"this is either a rep nodeid or a sub nodeid should have already been merged to its field-insensitive base! ");
201 for (FunctionSet::iterator
cit =
it->second.begin(),
231 for (FunctionSet::iterator
cit =
it->second.begin(),
261 <<
cs_arg->toString() <<
"\n");
405 assert(
gepNode &&
"Not a gep node in redundantGepNodes set");
407 GepObjVarMap.erase(std::make_pair(base, apOffset));
408 memToFieldsMap[base].reset(
n);
597 assert((SVFUtil::isa<CopyCGEdge>(
edge)) &&
"not copy/call/ret ??");
627 if (SVFUtil::isa<VariantGepCGEdge>(
edge))
670 assert(
false &&
"Andersen::processGepPts: New type GEP edge type?");
919 assert(
Options::MaxFieldLimit() == 0 &&
"Andersen::cluster: clustering for Andersen's is currently only supported in field-insensitive analysis");
921 std::vector<std::pair<unsigned, unsigned>>
keys;
924 keys.push_back(std::make_pair(
pit->first, 1));
927 std::vector<std::pair<hclust_fast_methods, std::vector<NodeID>>> candidates;
945 if (
getPAG()->isValidTopLevelPtr(node))
948 outs() <<
"\nNodeID " << node->
getId() <<
" ";
952 outs() <<
"\t\tPointsTo: {empty}\n";
956 outs() <<
"\t\tPointsTo: { ";
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
static double timeOfSCCMerges
static u32_t numOfProcessedCopy
Number of processed Addr edge.
static u32_t numOfSCCDetection
virtual void normalizePointsTo() override
static u32_t numOfSfrs
Number of processed Store edge.
virtual void finalize() override
Finalize analysis.
static double timeOfUpdateCallGraph
static u32_t numOfProcessedStore
Number of processed Load edge.
virtual void connectCaller2CalleeParams(const CallICFGNode *cs, const SVFFunction *F, NodePairSet &cpySrcNodes)
Connect formal and actual parameters for indirect callsites.
static u32_t numOfProcessedAddr
Statistics.
virtual bool updateCallGraph(const CallSiteToFunPtrMap &) override
Update call graph.
void printStat()
dump statistics
void heapAllocatorViaIndCall(const CallICFGNode *cs, NodePairSet &cpySrcNodes)
CallSite2DummyValPN callsite2DummyValPN
virtual void readPtsFromFile(const std::string &filename)
static u32_t numOfProcessedLoad
Number of processed Gep edge.
static double timeOfSCCDetection
virtual bool addCopyEdge(NodeID src, NodeID dst)=0
Add copy edge on constraint graph.
virtual void initialize() override
Initialize analysis.
~AndersenBase() override
Destructor.
virtual void analyze() override
Andersen analysis.
static u32_t numOfFieldExpand
static double timeOfProcessLoadStore
static u32_t numOfProcessedGep
Number of processed Copy edge.
static double timeOfProcessCopyGep
static u32_t MaxPointsToSetSize
virtual void solveConstraints()
virtual bool updateThreadCallGraph(const CallSiteToFunPtrMap &, NodePairSet &)
Update thread call graph.
static double timeOfCollapse
static u32_t AveragePointsToSetSize
virtual void solveAndwritePtsToFile(const std::string &filename)
ConstraintGraph * consCG
Constraint Graph.
void cleanConsCG(NodeID id)
remove redundant gepnodes in constraint graph
virtual void connectCaller2ForkedFunParams(const CallICFGNode *cs, const SVFFunction *F, NodePairSet &cpySrcNodes)
Connect formal and actual parameters for indirect forksites.
NodeID sccRepNode(NodeID id) const override
SCC methods.
virtual void handleLoadStore(ConstraintNode *node)
void mergeSccNodes(NodeID repNodeId, const NodeBS &subNodes)
Merge sub node in a SCC cycle to their rep node.
virtual void processNode(NodeID nodeId)
Override WPASolver function in order to use the default solver.
virtual void initialize()
Initialize analysis.
virtual NodeStack & SCCDetect()
SCC detection.
virtual void mergeNodeToRep(NodeID nodeId, NodeID newRepId)
Merge sub node to its rep.
bool collapseNodePts(NodeID nodeId)
void updatePropaPts(NodeID dstId, NodeID srcId)
Handle propagated points-to set.
virtual void computeDiffPts(NodeID id)
Handle diff points-to set.
virtual bool addCopyEdge(NodeID src, NodeID dst)
Add copy edge on constraint graph.
void resetData()
Reset data.
virtual const PointsTo & getDiffPts(NodeID id)
virtual bool processGep(NodeID node, const GepCGEdge *edge)
virtual void handleCopyGep(ConstraintNode *node)
virtual bool unionPts(NodeID id, const PointsTo &target)
virtual bool processLoad(NodeID node, const ConstraintEdge *load)
virtual const PointsTo & getPts(NodeID id)
Operation of points-to set.
void collapseFields()
collapse positive weight cycles of a graph
virtual bool processStore(NodeID node, const ConstraintEdge *load)
virtual bool processCopy(NodeID node, const ConstraintEdge *edge)
virtual bool processGepPts(const PointsTo &pts, const GepCGEdge *edge)
virtual void processAddr(const AddrCGEdge *addr)
void updateNodeRepAndSubs(NodeID nodeId, NodeID newRepId)
Updates subnodes of its rep, and rep node of its subs.
virtual void finalize()
Finalize analysis.
void processAllAddr()
handling various constraints
virtual void cluster(void) const
virtual bool mergeSrcToTgt(NodeID srcId, NodeID tgtId)
virtual void collapsePWCNode(NodeID nodeId)
Collapse a field object into its base for field insensitive analysis.
bool collapseField(NodeID nodeId)
virtual void writeToFile(const std::string &filename)
Interface for analysis result storage on filesystem.
virtual bool readFromFile(const std::string &filename)
virtual void writeObjVarToFile(const std::string &filename)
const NodeSet & getRevPts(NodeID nodeId) override
virtual void clearPts(NodeID id, NodeID element)
Remove element from the points-to set of id.
void finalize() override
Finalization of pointer analysis, and normalize points-to information to Bit Vector representation.
virtual void onTheFlyThreadCallGraphSolve(const CallSiteToFunPtrMap &callsites, CallEdgeMap &newForkEdges)
On the fly thread call graph construction respecting forksite.
virtual void onTheFlyCallGraphSolve(const CallSiteToFunPtrMap &callsites, CallEdgeMap &newEdges)
On the fly call graph construction.
PTData< NodeID, NodeSet, NodeID, PointsTo > PTDataTy
PTDataTy * getPTDataTy() const
Get points-to data structure.
virtual bool addPts(NodeID id, NodeID ptd)
const RetICFGNode * getRetICFGNode() const
Return callsite.
const std::string getSourceLoc() const override
const SVFFunction * getCalledFunction() const
NodeID getNextCollapseNode()
void setPWCNode(NodeID nodeId)
void setSubs(NodeID node, NodeBS &subs)
void addNodeToBeCollapsed(NodeID id)
NodeID sccRepNode(NodeID id) const
SCC rep/sub nodes methods.
void addConstraintNode(ConstraintNode *node, NodeID id)
void resetSubs(NodeID node)
NodeID getGepObjVar(NodeID id, const APOffset &apOffset)
Get a field of a memory object.
NodeID getBaseObjVar(NodeID id)
NodeID getFIObjVar(NodeID id)
Get a field-insensitive node of a memory object.
NodeBS & getSubs(NodeID node)
bool isPWCNode(NodeID nodeId)
Check/Set PWC (positive weight cycle) flag.
bool isBlkObjOrConstantObj(NodeID id)
void removeConstraintNode(ConstraintNode *node)
void resetRep(NodeID node)
ConstraintNode * getConstraintNode(NodeID id) const
Get/add/remove constraint node.
bool hasNodesToBeCollapsed() const
Add/get nodes to be collapsed.
void print()
Print CG into terminal.
bool moveEdgesToRepNode(ConstraintNode *node, ConstraintNode *rep)
NodeBS & sccSubNodes(NodeID id)
void setRep(NodeID node, NodeID rep)
NodeID getRep(NodeID node)
NodeBS & getAllFieldsObjVars(NodeID id)
void dump(std::string name)
Dump graph into dot file.
bool isPWCNode() const
Whether a node involves in PWC, if so, all its points-to elements should become field-insensitive.
const_iterator outgoingLoadsEnd() const
const ConstraintEdge::ConstraintEdgeSetTy & getGepOutEdges() const
const_iterator incomingStoresBegin() const
const_iterator incomingStoresEnd() const
ConstraintEdge::ConstraintEdgeSetTy::const_iterator const_iterator
const ConstraintEdge::ConstraintEdgeSetTy & getCopyOutEdges() const
const_iterator outgoingLoadsBegin() const
NodeID getSrcID() const
get methods of the components
iterator begin()
Iterators.
void removeGNode(NodeType *node)
Delete a node.
IDToNodeMapTy::const_iterator const_iterator
bool hasGNode(NodeID id) const
Has a node.
IDToNodeMapTy::iterator iterator
Node Iterators.
NodeType * getGNode(NodeID id) const
Get a node.
NodeID getVarargNode(const SVFFunction *func) const
getVarargNode - Return the unique node representing the variadic argument of a variadic function.
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 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< u32_t > AnderTimeLimit
Time limit for the Andersen's analyses.
static const Option< bool > PrintFieldWithBasePrefix
static const Option< std::string > ReadAnder
static const Option< bool > ClusterAnder
Whether to stage Andersen's with Steensgaard and cluster based on that data.
static const Option< bool > PrintCGGraph
static const Option< u32_t > MaxFieldLimit
Maximum number of field derivations for an object.
static const Option< std::string > WriteAnder
static const Option< bool > ConsCGDotGraph
bool isFieldInsensitive(NodeID id) const
OrderedMap< const CallICFGNode *, FunctionSet > CallEdgeMap
virtual void initialize()
Initialization of a pointer analysis, including building symbol table and SVFIR etc.
PTAStat * stat
Statistics.
OrderedNodeSet & getAllValidPtrs()
Get all Valid Pointers for resolution.
const CallSiteToFunPtrMap & getIndirectCallsites() const
Return all indirect callsites.
void setObjFieldInsensitive(NodeID id)
PTACallGraph * callgraph
Call graph used for pointer analysis.
SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap
std::shared_ptr< std::vector< NodeID > > MappingPtr
static void setCurrentBestNodeMapping(MappingPtr newCurrentBestNodeMapping, MappingPtr newCurrentBestReverseNodeMapping)
void set(u32_t n)
Inserts n in the set.
static MappingPtr getCurrentBestNodeMapping()
virtual const SVFType * getType() const
NodeID getId() const
Get ID.
const std::string valueOnlyToString() const
bool isConstantObj(NodeID id) const
std::vector< const SVFVar * > SVFVarList
const SVFVarList & getFunArgsList(const SVFFunction *func) const
Get function arguments list.
NodeID getBaseObjVar(NodeID id) const
Base and Offset methods for Value and Object node.
const SVFVar * getFunRet(const SVFFunction *func) const
Get function return list.
bool hasCallSiteArgsMap(const CallICFGNode *cs) const
Callsite has argument list.
NodeOffsetMap & getGepObjNodeMap()
Return GepObjVarMap.
bool callsiteHasRet(const RetICFGNode *cs) const
Map< NodeID, NodeBS > MemObjToFieldsMap
bool hasFunArgsList(const SVFFunction *func) const
Function has arguments list.
const SVFVarList & getCallSiteArgsList(const CallICFGNode *cs) const
Get callsite argument list.
const SVFVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
Map< NodeOffset, NodeID > NodeOffsetMap
NodeID addDummyObjNode(const SVFType *type)
MemObjToFieldsMap & getMemToFieldsMap()
Return memToFieldsMap.
bool funHasRet(const SVFFunction *func) const
static double getClk(bool mark=false)
virtual bool isPointer() const
Whether it is a pointer.
static Steensgaard * createSteensgaard(SVFIR *_pag)
Create an singleton instance.
SCC * getSCCDetector() const
Get SCC detector.
virtual void pushIntoWorklist(NodeID id)
virtual void initWorklist()
void setGraph(GraphType g)
virtual NodeStack & SCCDetect()
SCC detection.
u32_t iterationForPrintStat
print out statistics for i-th iteration
u32_t numOfIteration
num of iterations during constraint solving
bool reanalyze
Reanalyze if any constraint value changed.
virtual void solveWorklist()
void stopAnalysisLimitTimer(bool limitTimerSet)
bool isHeapAllocExtFunViaRet(const SVFFunction *fun)
Return true if the call is a heap allocator/reallocator.
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
bool startAnalysisLimitTimer(unsigned timeLimit)
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
std::ostream & outs()
Overwrite llvm::outs()
std::stack< NodeID > NodeStack
llvm::IRBuilder IRBuilder
Set< NodePair > NodePairSet