40using namespace SVFUtil;
52 dump(
"SVFG_before_opt");
100 candidates.insert(node);
104 for (SVFGNodeSet::const_iterator
it = candidates.begin(),
eit = candidates.end();
118 else if (SVFUtil::isa<ActualParmSVFGNode, FormalRetSVFGNode>(node))
122 else if (SVFUtil::isa<ActualINSVFGNode, FormalOUTSVFGNode>(node))
127 else if (SVFUtil::isa<ActualOUTSVFGNode, FormalINSVFGNode>(node))
139 if (SVFUtil::isa<ActualOUTSVFGNode, FormalINSVFGNode>(node))
153 assert((SVFUtil::isa<FormalParmSVFGNode, ActualRetSVFGNode>(
svfgNode))
154 &&
"expecting a formal param or actual ret svfg node");
206 assert(node->
getInEdges().size() == 1 &&
"actual-in/formal-out can only have one incoming edge as its def size");
218 def =
inEdge->getSrcNode();
219 if (SVFUtil::isa<ActualINSVFGNode>(node))
221 else if (SVFUtil::isa<FormalOUTSVFGNode>(node))
241 assert(
false &&
"expecting an inter-procedural SVFG edge");
301 if (SVFUtil::isa<CallIndSVFGEdge, RetIndSVFGEdge>(*
edgeIt))
312 if (SVFUtil::isa<CallIndSVFGEdge, RetIndSVFGEdge>(*
edgeIt))
461 SVFUtil::isa<CallIndSVFGEdge, RetIndSVFGEdge>(
preEdge))
468 assert(SVFUtil::isa<IndirectSVFGEdge>(
preEdge) &&
"can only remove indirect SVFG edge");
526 &&
"either pre or succ edge is not indirect SVFG edge");
static std::string KeepNoneSelfCycle
static std::string KeepContextSelfCycle
static std::string KeepAllSelfCycle
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
const PAGNode * getParam() const
Return parameter.
const CallICFGNode * getCallSite() const
Return callsite.
iterator begin()
Iterators.
bool hasIncomingEdge() const
Has incoming/outgoing edge set.
bool hasOutgoingEdge() const
const GEdgeSetTy & getInEdges() const
iterator OutEdgeBegin()
iterators
virtual const SVFFunction * getFun() const
Return the function of this ICFGNode.
static const Option< bool > KeepAOFI
static const Option< std::string > SelfCycle
static const Option< bool > DumpVFG
static const Option< bool > ContextInsensitive
NodeID getId() const
Get ID.
Set< SVFGNode * > SVFGNodeSet
bool isDefOfAInFOut(const SVFGNode *node)
SVFGEdge * addCallIndirectSVFGEdge(NodeID srcId, NodeID dstId, CallSiteID csid, const NodeBS &cpts)
Add inter-procedural value flow edge.
void replaceFParamARetWithPHI(PHISVFGNode *phi, SVFGNode *svfgNode)
Replace FormalParam/ActualRet node with PHI node.
void handleIntraValueFlow()
Remove MSSAPHI SVFG nodes.
void retargetEdgesOfAOutFIn(SVFGNode *node)
Connect actual-out/formal-in's predecessors to their successors directly.
void addInterPHIOperands(PHISVFGNode *phi, const PAGNode *operand)
void setFormalOUTDef(NodeID fo, NodeID def)
void setActualINDef(NodeID ai, NodeID def)
void handleInterValueFlow()
void bypassMSSAPHINode(const MSSAPHISVFGNode *node)
Remove MSSAPHI node if possible.
void removeInEdges(const SVFGNode *node)
bool addNewSVFGEdge(NodeID srcId, NodeID dstId, const SVFGEdge *preEdge, const SVFGEdge *succEdge)
Add new SVFG edge from src to dst.
bool bothInterEdges(const SVFGEdge *edge1, const SVFGEdge *edge2) const
Return TRUE if both edges are indirect call/ret edges.
bool formalInOfAddressTakenFunc(const FormalINSVFGNode *fi) const
Check if formal-in/formal-out reside in address-taken function.
bool addIntoWorklist(const SVFGNode *node)
void buildSVFG() override
Start building SVFG.
bool actualOutOfIndCS(const ActualOUTSVFGNode *ao) const
bool keepActualOutFormalIn
InterPHISVFGNode * addInterPHIForAR(const ActualRetSVFGNode *ar)
Add inter PHI SVFG node for actual return.
bool formalOutOfAddressTakenFunc(const FormalOUTSVFGNode *fo) const
WorkList worklist
storing MSSAPHI nodes which may be removed.
InterPHISVFGNode * addInterPHIForFP(const FormalParmSVFGNode *fp)
Add inter PHI SVFG node for formal parameter.
bool isConnectingTwoCallSites(const SVFGNode *node) const
Return TRUE if this node has both incoming call/ret and outgoing call/ret edges.
bool canBeRemoved(const SVFGNode *node)
void retargetEdgesOfAInFOut(SVFGNode *node)
Retarget edges related to actual-in/-out and formal-in/-out.
void removeAllEdges(const SVFGNode *node)
Remove edges of a SVFG node.
void parseSelfCycleHandleOption()
bool keepContextSelfCycle
void initialWorkList()
Initial work list with MSSAPHI nodes which may be removed.
void removeOutEdges(const SVFGNode *node)
bool actualInOfIndCS(const ActualINSVFGNode *ai) const
Check if actual-in/actual-out exist at indirect call site.
SVFGEdge * addRetIndirectSVFGEdge(NodeID srcId, NodeID dstId, CallSiteID csid, const NodeBS &cpts)
Add indirect ret edge from src to dst with one call site ID.
bool checkSelfCycleEdges(const MSSAPHISVFGNode *node)
Remove self cycle edges if needed. Return TRUE if some self cycle edges remained.
virtual void buildSVFG()
Start building SVFG.
void dump(const std::string &file, bool simple=false)
Dump graph into dot file.
void removeSVFGNode(SVFGNode *node)
Remove a SVFGNode.
SVFGEdge * addRetIndirectVFEdge(NodeID srcId, NodeID dstId, const NodeBS &cpts, CallSiteID csId)
void removeSVFGEdge(SVFGEdge *edge)
Remove a SVFG edge.
NodeID getDef(const PAGNode *pagNode) const
SVFGEdge * addIntraIndirectVFEdge(NodeID srcId, NodeID dstId, const NodeBS &cpts)
Add indirect def-use edges of a memory region between two statements,.
SVFGEdge * addCallIndirectVFEdge(NodeID srcId, NodeID dstId, const NodeBS &cpts, CallSiteID csId)
VFGEdgeSetTy SVFGEdgeSetTy
VFGEdge::VFGEdgeSetTy::const_iterator const_iterator
VFGEdge::VFGEdgeSetTy::iterator iterator
VFGEdge * addRetEdge(NodeID srcId, NodeID dstId, CallSiteID csId)
VFGEdge * addIntraDirectVFEdge(NodeID srcId, NodeID dstId)
CallSiteID getCallSiteID(const CallICFGNode *cs, const SVFFunction *func) const
Get callsite given a callsiteID.
VFGEdge * addCallEdge(NodeID srcId, NodeID dstId, CallSiteID csId)
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
LLVM_NODISCARD bool isa(const Y &Val)
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
std::ostream & outs()
Overwrite llvm::outs()
llvm::IRBuilder IRBuilder