38using namespace SVFUtil;
101 if (
it->second->getFunction()->isDeclaration())
121 if (
it->second->getInEdges().empty())
123 for (
auto inEdge:
it->second->getInEdges())
130 if (
inEdge->isDirectCallEdge())
132 else if (
inEdge->isIndirectCallEdge())
135 assert(
false &&
"CallGraphEdge must "
136 "be either direct or indirect!");
153 assert(
false &&
"Invalid recursion mode specified!");
190 std::vector<AbstractState>
workList;
198 SVFUtil::dyn_cast<IntraCFGEdge>(
edge))
218 SVFUtil::dyn_cast<CallCFGEdge>(
edge))
226 SVFUtil::dyn_cast<RetCFGEdge>(
edge))
246 assert(
false &&
"Unhandled ICFGEdge type encountered!");
294 if (!
loadVar0->getInEdges().empty())
304 if (!
loadVar0->getInEdges().empty())
316 if (!
loadVar1->getInEdges().empty())
326 if (!
loadVar1->getInEdges().empty())
393 for (
const auto &
addr: addrs)
415 for (
const auto &
addr: addrs)
433 for (
const auto &
addr: addrs)
452 for (
const auto &
addr: addrs)
471 for (
const auto &
addr: addrs)
487 assert(
false &&
"implement this part");
513 if (SVFUtil::isa<CopyStmt>(
stmt))
518 else if (
const LoadStmt* load = SVFUtil::dyn_cast<LoadStmt>(
stmt))
520 if (
new_es.inVarToAddrsTable(load->getRHSVarID()))
523 for (
const auto &
addr: addrs)
542 if (
cmpVar->getInEdges().empty())
571 std::deque<const ICFGNode*> worklist;
620 assert(
false &&
"unknown WTO type!");
644 assert(
false &&
"implement this part");
647 assert (
false &&
"it is not call node");
685 if (
retNode->getSVFStmts().size() > 0)
687 if (
const RetPE *retPE = SVFUtil::dyn_cast<RetPE>(*
retNode->getSVFStmts().begin()))
689 if (!retPE->getLHSVar()->isPointer() &&
690 !retPE->getLHSVar()->isConstDataOrAggDataButNotNullPtr())
814 assert(
false &&
"Recursion mode TOP should not reach here!");
854 assert(
false &&
"Recursion mode TOP should not reach here");
894 else if (SVFUtil::isa<UnaryOPStmt>(
stmt))
897 else if (SVFUtil::isa<BranchStmt>(
stmt))
901 else if (
const LoadStmt *load = SVFUtil::dyn_cast<LoadStmt>(
stmt))
905 else if (
const StoreStmt *store = SVFUtil::dyn_cast<StoreStmt>(
stmt))
930 else if (
const RetPE *retPE = SVFUtil::dyn_cast<RetPE>(
stmt))
935 assert(
false &&
"implement this part");
945 if (
retNode->getSVFStmts().size() > 0)
947 if (
const RetPE *retPE = SVFUtil::dyn_cast<RetPE>(*
retNode->getSVFStmts().begin()))
950 if (!retPE->getLHSVar()->isPointer() && !retPE->getLHSVar()->isConstDataOrAggDataButNotNullPtr())
954 if (!
retNode->getOutEdges().empty())
956 if (
retNode->getOutEdges().size() == 1)
969 for (
const ICFGNode* node: bb->getICFGNodeList())
973 if (
const StoreStmt *store = SVFUtil::dyn_cast<StoreStmt>(
stmt))
977 if (
as.inVarToAddrsTable(
lhs))
979 if (!
rhsVar->isPointer() && !
rhsVar->isConstDataOrAggDataButNotNullPtr())
1024 if (
it.second->getFun())
1026 funs.insert(
it.second->getFun());
1052 if (
fullName.find(
'/') == std::string::npos)
1070 std::cout << std::setw(
field_width) <<
it->first <<
it->second <<
"\n";
1072 SVFUtil::outs() <<
"-------------------------------------------------------\n";
1080 SVFUtil::outs() <<
"#######################################################" << std::endl;
1094 if (
const CallICFGNode *call = SVFUtil::dyn_cast<CallICFGNode>(node))
1096 if (
const FunObjVar *fun = call->getCalledFunction())
1163 if (
as[cond].getInterval().is_numeral())
1233 as.initObjVar(SVFUtil::cast<ObjVar>(
addr->getRHSVar()));
1254 switch (
binary->getOpcode())
1297 assert(
false &&
"undefined binary: ");
1308 if (
as.inVarToAddrsTable(
op0) &&
as.inVarToAddrsTable(
op1))
1337 if (!
as.inVarToValTable(
op0))
1339 if (!
as.inVarToValTable(
op1))
1342 if (
as.inVarToValTable(
op0) &&
as.inVarToValTable(
op1))
1345 if (
as[
op0].isInterval() &&
as[
op1].isInterval())
1350 auto predicate =
cmp->getPredicate();
1395 assert(
false &&
"undefined compare: ");
1399 else if (
as[
op0].isAddr() &&
as[
op1].isAddr())
1403 auto predicate =
cmp->getPredicate();
1410 if (
lhs.hasIntersect(
rhs))
1414 else if (
lhs.empty() &&
rhs.empty())
1428 if (
lhs.hasIntersect(
rhs))
1432 else if (
lhs.empty() &&
rhs.empty())
1447 if (
lhs.size() == 1 &&
rhs.size() == 1)
1462 if (
lhs.size() == 1 &&
rhs.size() == 1)
1477 if (
lhs.size() == 1 &&
rhs.size() == 1)
1492 if (
lhs.size() == 1 &&
rhs.size() == 1)
1509 assert(
false &&
"undefined compare: ");
1538 if (SVFUtil::isa<SVFIntegerType>(
type))
1541 if (
as[
var->getId()].getInterval().is_numeral())
1549 else if (
bits == 16)
1555 else if (
bits == 32)
1561 else if (
bits == 64)
1568 assert(
false &&
"cannot support int type other than u8/16/32/64");
1582 if(
itv.isBottom())
return itv;
1625 assert(
false &&
"cannot support dst int type other than u8/16/32");
1678 if (
as[
rhs].isAddr())
1688 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)
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.
const std::vector< const ICFGNode * > & getSubNodes(const ICFGNode *node) const
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 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 OptionMap< AbstractInterpretation::HandleRecur > HandleRecur
recursion handling mode, Default: TOP
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.
CallGraph * getCallGraph()
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