47using namespace SVFUtil;
207 assert(!
consCG->
hasGNode(
id) &&
"this is either a rep nodeid or a sub nodeid should have already been merged to its field-insensitive base! ");
221 for (FunctionSet::iterator
cit = it->second.begin(),
222 ecit = it->second.end();
231 for (NodePairSet::iterator it =
cpySrcNodes.begin(),
251 for (FunctionSet::iterator
cit = it->second.begin(),
252 ecit = it->second.end();
281 <<
cs_arg->toString() <<
"\n");
425 assert(
gepNode &&
"Not a gep node in redundantGepNodes set");
427 GepObjVarMap.erase(std::make_pair(base, apOffset));
428 memToFieldsMap[base].reset(
n);
619 assert((SVFUtil::isa<CopyCGEdge>(
edge)) &&
"not copy/call/ret ??");
649 if (SVFUtil::isa<VariantGepCGEdge>(
edge))
692 assert(
false &&
"Andersen::processGepPts: New type GEP edge type?");
743 if (subNodes.
count() > 1)
1009 getPts(representative).test(
object))
1061 outs() <<
sucMsg(
"\t SUCCESS :") <<
"getMayAliases check <id:" <<
ptr <<
"> at ("
1062 <<
callNode->getSourceLoc() <<
")\n";
1066 <<
"> at (" <<
callNode->getSourceLoc() <<
")\n";
1067 assert(
false &&
"getMayAliases disagrees with mayAlias!");
1075 assert(
Options::MaxFieldLimit() == 0 &&
"Andersen::cluster: clustering for Andersen's is currently only supported in field-insensitive analysis");
1077 std::vector<std::pair<unsigned, unsigned>>
keys;
1080 keys.push_back(std::make_pair(
pit->first, 1));
1083 std::vector<std::pair<hclust_fast_methods, std::vector<NodeID>>> candidates;
1085 std::make_shared<std::vector<NodeID>>(
1103 if (
getPAG()->isValidTopLevelPtr(node))
1106 outs() <<
"\nNodeID " << node->
getId() <<
" ";
1110 outs() <<
"\t\tPointsTo: {empty}\n";
1114 outs() <<
"\t\tPointsTo: { ";
1128 outs() << *it <<
" ";
1130 outs() << *it <<
" ";
#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.
NodeBS & sccSubNodes(NodeID repId)
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 connectCaller2ForkedFunParams(const CallICFGNode *cs, const FunObjVar *F, NodePairSet &cpySrcNodes)
Connect formal and actual parameters for indirect forksites.
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.
virtual void connectCaller2CalleeParams(const CallICFGNode *cs, const FunObjVar *F, NodePairSet &cpySrcNodes)
Connect formal and actual parameters for indirect callsites.
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
NodeID sccRepNode(NodeID id) const override
SCC methods.
virtual void handleLoadStore(ConstraintNode *node)
virtual NodeBS getMayAliases(NodeID node)
Collect exactly the SVFIR nodes q for which mayAlias(node, q) holds.
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.
std::optional< NodeBS > collectMayAliasesFromIndex(const PointsTo &expandedPts)
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.
virtual void validateSuccessTests(std::string fun)
Also check getMayAliases on the pointers that the alias tests use.
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.
bool mayAlias(const PointsTo &pts1, const PointsTo &pts2)
Convenience bool wrappers: return true if the two operands may/must/partial alias.
virtual void expandFIObjs(const PointsTo &pts, PointsTo &expandedPts)
Expand FI objects.
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)
NodeID getId() const
Get the memory object id.
const FunObjVar * getCalledFunction() const
const RetICFGNode * getRetICFGNode() const
Return callsite.
const std::string getSourceLoc() const override
NodeID getNextCollapseNode()
void setPWCNode(NodeID nodeId)
void setSubs(NodeID node, NodeBS &subs)
void addNodeToBeCollapsed(NodeID id)
NodeID getBaseObjVarID(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 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)
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_iterator incomingAddrsBegin() 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 incomingAddrsEnd() const
const_iterator outgoingLoadsBegin() const
static const size_t WordSize
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.
u32_t getTotalNodeNum() const
Get total number of node/edge.
IDToNodeMapTy::iterator iterator
Node Iterators.
NodeID getBlackHoleNode() const
NodeID getVarargNode(const FunObjVar *func) const
getVarargNode - Return the unique node representing the variadic argument of a variadic function.
static std::vector< NodeID > getReverseNodeMapping(const std::vector< NodeID > &nodeMapping)
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="", bool printStat=true)
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< u32_t > FsTimeLimit
Time limit for the main phase (i.e., the actual solving) of FS analyses.
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
virtual NodeBS getMayAliases(NodeID node)
bool isFieldInsensitive(NodeID id) const
bool print_stat
User input flags.
OrderedMap< const CallICFGNode *, FunctionSet > CallEdgeMap
virtual void initialize()
Initialization of a pointer analysis, including building symbol table and SVFIR etc.
bool containBlackHoleNode(const PointsTo &pts)
Determine whether a points-to contains a black hole or constant node.
PTAStat * stat
Statistics.
OrderedNodeSet & getAllValidPtrs()
Get all Valid Pointers for resolution.
virtual void validateSuccessTests(std::string fun)
const CallSiteToFunPtrMap & getIndirectCallsites() const
Return all indirect callsites.
CallGraph * callgraph
Call graph used for pointer analysis.
void setObjFieldInsensitive(NodeID id)
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()
const CallSiteSet & getCallSiteSet() const
Get all callsites.
bool funHasRet(const FunObjVar *func) const
bool hasFunArgsList(const FunObjVar *func) const
Function has arguments list.
NodeID getBaseObjVarID(NodeID id) const
Base and Offset methods for Value and Object node.
const ValVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
const ValVarList & getFunArgsList(const FunObjVar *func) const
Get function arguments list.
std::vector< const ValVar * > ValVarList
bool isConstantObj(NodeID id) const
const FunObjVar * getFunObjVar(const std::string &name)
bool hasCallSiteArgsMap(const CallICFGNode *cs) const
Callsite has argument list.
NodeBS & getAllFieldsObjVars(const BaseObjVar *obj)
Get all fields of an object.
const SVFVar * getSVFVar(NodeID id) const
ObjVar/GepObjVar/BaseObjVar.
bool callsiteHasRet(const RetICFGNode *cs) const
OffsetToGepVarMap & getGepObjNodeMap()
Return GepObjVarMap.
Map< NodeID, NodeBS > MemObjToFieldsMap
Map< GepOffset, NodeID > OffsetToGepVarMap
const ValVar * getFunRet(const FunObjVar *func) const
Get function return list.
const ValVarList & getCallSiteArgsList(const CallICFGNode *cs) const
Get callsite argument list.
const GepObjVar * getGepObjVar(NodeID id) const
NodeID addDummyObjNode(const SVFType *type)
MemObjToFieldsMap & getMemToFieldsMap()
Return memToFieldsMap.
static double getClk(bool mark=false)
NodeID getId() const
Get ID.
virtual const SVFType * getType() const
const std::string valueOnlyToString() const
virtual bool isPointer() const
Check if this variable represents 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()
std::string sucMsg(const std::string &msg)
Returns successful message by converting a string into green string output.
bool isHeapAllocExtFunViaRet(const FunObjVar *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.
void stopAnalysisLimitTimer(void)
Stops analysis timer.
std::string errMsg(const std::string &msg)
Print error message by converting a string into red string output.
std::ostream & errs()
Overwrite llvm::errs()
void startAnalysisLimitTimer(unsigned timeLimit)
Starts analysis timer. timeLimit must be non-0. Timer must not be already set.
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