39using namespace SVFUtil;
102 if (
it->second->getFunction()->isDeclaration())
122 if (
it->second->getInEdges().empty())
124 for (
auto inEdge:
it->second->getInEdges())
131 if (
inEdge->isDirectCallEdge())
133 else if (
inEdge->isIndirectCallEdge())
136 assert(
false &&
"CallGraphEdge must "
137 "be either direct or indirect!");
154 assert(
false &&
"Invalid recursion mode specified!");
191 std::vector<AbstractState>
workList;
199 SVFUtil::dyn_cast<IntraCFGEdge>(
edge))
219 SVFUtil::dyn_cast<CallCFGEdge>(
edge))
227 SVFUtil::dyn_cast<RetCFGEdge>(
edge))
247 assert(
false &&
"Unhandled ICFGEdge type encountered!");
295 if (!
loadVar0->getInEdges().empty())
305 if (!
loadVar0->getInEdges().empty())
317 if (!
loadVar1->getInEdges().empty())
327 if (!
loadVar1->getInEdges().empty())
394 for (
const auto &
addr: addrs)
416 for (
const auto &
addr: addrs)
434 for (
const auto &
addr: addrs)
453 for (
const auto &
addr: addrs)
472 for (
const auto &
addr: addrs)
488 assert(
false &&
"implement this part");
514 if (SVFUtil::isa<CopyStmt>(
stmt))
519 else if (
const LoadStmt* load = SVFUtil::dyn_cast<LoadStmt>(
stmt))
521 if (
new_es.inVarToAddrsTable(load->getRHSVarID()))
524 for (
const auto &
addr: addrs)
543 if (
cmpVar->getInEdges().empty())
572 std::deque<const ICFGNode*> worklist;
616 assert(
false &&
"unknown WTO type!");
640 assert(
false &&
"implement this part");
643 assert (
false &&
"it is not call node");
681 if (
retNode->getSVFStmts().size() > 0)
683 if (
const RetPE *retPE = SVFUtil::dyn_cast<RetPE>(*
retNode->getSVFStmts().begin()))
685 if (!retPE->getLHSVar()->isPointer() &&
686 !retPE->getLHSVar()->isConstDataOrAggDataButNotNullPtr())
810 assert(
false &&
"Recursion mode TOP should not reach here!");
850 assert(
false &&
"Recursion mode TOP should not reach here");
890 else if (SVFUtil::isa<UnaryOPStmt>(
stmt))
893 else if (SVFUtil::isa<BranchStmt>(
stmt))
897 else if (
const LoadStmt *load = SVFUtil::dyn_cast<LoadStmt>(
stmt))
901 else if (
const StoreStmt *store = SVFUtil::dyn_cast<StoreStmt>(
stmt))
926 else if (
const RetPE *retPE = SVFUtil::dyn_cast<RetPE>(
stmt))
931 assert(
false &&
"implement this part");
941 if (
retNode->getSVFStmts().size() > 0)
943 if (
const RetPE *retPE = SVFUtil::dyn_cast<RetPE>(*
retNode->getSVFStmts().begin()))
946 if (!retPE->getLHSVar()->isPointer() && !retPE->getLHSVar()->isConstDataOrAggDataButNotNullPtr())
950 if (!
retNode->getOutEdges().empty())
952 if (
retNode->getOutEdges().size() == 1)
965 for (
const ICFGNode* node: bb->getICFGNodeList())
969 if (
const StoreStmt *store = SVFUtil::dyn_cast<StoreStmt>(
stmt))
973 if (
as.inVarToAddrsTable(
lhs))
975 if (!
rhsVar->isPointer() && !
rhsVar->isConstDataOrAggDataButNotNullPtr())
1020 if (
it.second->getFun())
1022 funs.insert(
it.second->getFun());
1048 if (
fullName.find(
'/') == std::string::npos)
1066 std::cout << std::setw(
field_width) <<
it->first <<
it->second <<
"\n";
1068 SVFUtil::outs() <<
"-------------------------------------------------------\n";
1076 SVFUtil::outs() <<
"#######################################################" << std::endl;
1090 if (
const CallICFGNode *call = SVFUtil::dyn_cast<CallICFGNode>(node))
1092 if (
const FunObjVar *fun = call->getCalledFunction())
1159 if (
as[cond].getInterval().is_numeral())
1229 as.initObjVar(SVFUtil::cast<ObjVar>(
addr->getRHSVar()));
1250 switch (
binary->getOpcode())
1293 assert(
false &&
"undefined binary: ");
1304 if (
as.inVarToAddrsTable(
op0) &&
as.inVarToAddrsTable(
op1))
1333 if (!
as.inVarToValTable(
op0))
1335 if (!
as.inVarToValTable(
op1))
1338 if (
as.inVarToValTable(
op0) &&
as.inVarToValTable(
op1))
1341 if (
as[
op0].isInterval() &&
as[
op1].isInterval())
1346 auto predicate =
cmp->getPredicate();
1391 assert(
false &&
"undefined compare: ");
1395 else if (
as[
op0].isAddr() &&
as[
op1].isAddr())
1399 auto predicate =
cmp->getPredicate();
1406 if (
lhs.hasIntersect(
rhs))
1410 else if (
lhs.empty() &&
rhs.empty())
1424 if (
lhs.hasIntersect(
rhs))
1428 else if (
lhs.empty() &&
rhs.empty())
1443 if (
lhs.size() == 1 &&
rhs.size() == 1)
1458 if (
lhs.size() == 1 &&
rhs.size() == 1)
1473 if (
lhs.size() == 1 &&
rhs.size() == 1)
1488 if (
lhs.size() == 1 &&
rhs.size() == 1)
1505 assert(
false &&
"undefined compare: ");
1534 if (SVFUtil::isa<SVFIntegerType>(
type))
1537 if (
as[
var->getId()].getInterval().is_numeral())
1545 else if (
bits == 16)
1551 else if (
bits == 32)
1557 else if (
bits == 64)
1564 assert(
false &&
"cannot support int type other than u8/16/32/64");
1578 if(
itv.isBottom())
return itv;
1622 assert(
false &&
"cannot support dst int type other than u8/16/32");
1677 if (
as[
rhs].isAddr())
1687 assert(
false &&
"undefined copy kind");
void performStat() override
u32_t & getICFGNodeTrace()
std::string getMemUsage()
AbstractInterpretation * _ae
Handles external API calls and manages abstract states.
void handleExtAPI(const CallICFGNode *call)
Handles an external API call.
IntervalValue getRangeLimitFromType(const SVFType *type)
Gets the range limit from a type.
void updateStateOnCall(const CallPE *callPE)
virtual bool isRecursiveCall(const CallICFGNode *callNode)
virtual void recursiveCallPass(const CallICFGNode *callNode)
void updateStateOnStore(const StoreStmt *store)
virtual bool isDirectCall(const CallICFGNode *callNode)
bool hasAbsStateFromTrace(const ICFGNode *node)
virtual void handleCycleWTO(const ICFGCycleWTO *cycle)
handle wto cycle (loop)
Set< const FunObjVar * > recursiveFuns
void updateStateOnGep(const GepStmt *gep)
void analyse()
Program entry.
virtual void extCallPass(const CallICFGNode *callNode)
virtual void handleGlobalNode()
Global ICFGNode is handled at the entry of the program,.
bool mergeStatesFromPredecessors(const ICFGNode *icfgNode)
virtual void directCallFunPass(const CallICFGNode *callNode)
void handleWTOComponent(const ICFGWTOComp *wtoComp)
virtual bool isExtCall(const CallICFGNode *callNode)
virtual bool isIndirectCall(const CallICFGNode *callNode)
void initWTO()
Compute IWTO for each function partition entry.
AbstractInterpretation()
Constructor.
void updateStateOnPhi(const PhiStmt *phi)
bool isBranchFeasible(const IntraCFGEdge *intraEdge, AbstractState &as)
std::vector< std::unique_ptr< AEDetector > > detectors
AbstractState & getAbsStateFromTrace(const ICFGNode *node)
Retrieves the abstract state from the trace for a given ICFG node.
Set< const CallICFGNode * > checkpoints
bool isSwitchBranchFeasible(const SVFVar *var, s64_t succ, AbstractState &as)
Map< s32_t, s32_t > _reverse_predicate
void updateStateOnSelect(const SelectStmt *select)
virtual void handleSVFStatement(const SVFStmt *stmt)
virtual void indirectCallFunPass(const CallICFGNode *callNode)
SVFIR * svfir
protected data members, also used in subclasses
virtual void runOnModule(ICFG *icfg)
virtual bool isRecursiveCallSite(const CallICFGNode *callNode, const FunObjVar *)
virtual bool isRecursiveFun(const FunObjVar *fun)
void updateStateOnAddr(const AddrStmt *addr)
virtual ~AbstractInterpretation()
Destructor.
bool isCmpBranchFeasible(const CmpStmt *cmpStmt, s64_t succ, AbstractState &as)
virtual void handleCallSite(const ICFGNode *node)
void updateStateOnRet(const RetPE *retPE)
void handleWTOComponents(const std::list< const ICFGWTOComp * > &wtoComps)
Handle two types of WTO components (singleton and cycle)
void updateStateOnCopy(const CopyStmt *copy)
Set< std::pair< const CallICFGNode *, NodeID > > nonRecursiveCallSites
void updateStateOnLoad(const LoadStmt *load)
void updateStateOnBinary(const BinaryOPStmt *binary)
Map< const ICFGNode *, AbstractState > abstractTrace
std::vector< const CallICFGNode * > callSiteStack
virtual void handleSingletonWTO(const ICFGSingletonWTO *icfgSingletonWto)
handle instructions in svf basic blocks
Map< s32_t, s32_t > _switch_lhsrhs_predicate
void updateStateOnCmp(const CmpStmt *cmp)
virtual void SkipRecursiveCall(const CallICFGNode *callnode)
Map< const FunObjVar *, const ICFGWTO * > funcToWTO
AbstractState widening(const AbstractState &other)
domain widen with other, and return the widened domain
AddressValue & getAddrs()
bool meet_with(const AddressValue &other)
Return a intersected AddressValue.
AddrSet::const_iterator begin() const
static AndersenWaveDiff * createAndersenWaveDiff(SVFIR *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
NodeID getRHSVarID() const
NodeID getLHSVarID() const
s64_t getIntNumeral() const
const CallGraphNode * getCallGraphNode(const std::string &name) const
Get call graph node.
@ ICMP_SGT
signed greater than
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ ICMP_UGE
unsigned greater or equal
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ ICMP_ULE
unsigned less or equal
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
@ ICMP_ULT
unsigned less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ ICMP_SLT
signed less than
@ ICMP_UGT
unsigned greater than
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
@ ICMP_SGE
signed greater or equal
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ ICMP_SLE
signed less or equal
virtual const FunObjVar * getFunction() const
Get containing function, or null for globals/constants.
bool isDeclaration() const
iterator begin()
Iterators.
u32_t nodeNum
total num of edge
NodeType * getGNode(NodeID id) const
Get a node.
const GEdgeSetTy & getInEdges() const
virtual const std::string toString() const
const SVFStmtList & getSVFStmts() const
ICFGEdge * getICFGEdge(const ICFGNode *src, const ICFGNode *dst, ICFGEdge::ICFGEdgeK kind)
Get a SVFG edge according to src and dst.
FunEntryICFGNode * getFunEntryICFGNode(const FunObjVar *fun)
Add a function entry node.
GlobalICFGNode * getGlobalICFGNode() const
void meet_with(const IntervalValue &other)
Return a intersected IntervalValue.
static BoundedInt minus_infinity()
Get minus infinity -inf.
static BoundedInt plus_infinity()
Get plus infinity +inf.
static IntervalValue top()
Create the IntervalValue [-inf, +inf].
const BoundedInt & lb() const
Return the lower bound.
static const OptionMap< u32_t > HandleRecur
recursion handling mode, Default: TOP
static const Option< u32_t > MaxFieldLimit
Maximum number of field derivations for an object.
static const Option< u32_t > WidenDelay
static const Option< bool > NullDerefCheck
nullptr dereference checker, Default: false
static const Option< bool > PStat
static const Option< bool > BufferOverflowCheck
buffer overflow checker, Default: false
CallGraph * getCallGraph() const
Return call graph.
SCCDetection< CallGraph * > CallGraphSCC
CallGraphSCC * getCallGraphSCC() const
Return call graph SCC.
const CallGraph * getCallGraph()
Get CG.
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
ICFGNode * getICFGNode() const
u32_t getByteSize() const
std::string errMsg(const std::string &msg)
Print error message by converting a string into red string output.
std::ostream & errs()
Overwrite llvm::errs()
bool isExtCall(const FunObjVar *fun)
std::ostream & outs()
Overwrite llvm::outs()
llvm::IRBuilder IRBuilder