64 for (
const auto&
item: *svfirCallGraph)
99 double num = log(succ_number) / log(2);
101 u32_t succ_index = 0;
102 std::vector<Condition> condVec;
103 for (
u32_t i = 0; i < bit_num; i++)
118 for (
u32_t j = 0; j < bit_num; j++)
121 u32_t tool = 0x01 << j;
122 if (tool & succ_index)
128 path_cond =
condAnd(path_cond, condVec.at(j));
149 BBCondMap::const_iterator it =
bbConds.find(bb);
150 assert(it !=
bbConds.end() &&
"basic block does not have branch and conditions??");
151 CondPosMap::const_iterator cit = it->second.find(pos);
152 assert(cit != it->second.end() &&
"no condition on the branch??");
179 condPosMap[pos] = cond;
231 if (branch1 && !branch2)
241 else if (!branch1 && branch2)
251 else if (branch1 && branch2)
269 assert(svffun == dst->
getParent() &&
"two basic blocks should be in the same function");
274 std::vector<const SVFBasicBlock*> exitbbs;
280 filteredbbs.insert(eb);
285 for (
const auto &filteredbb: filteredbbs)
312 for (
const auto &svfStmt: icfgNode->getSVFStmts())
316 if (branchStmt->getNumSuccessors() == 2)
318 const SVFBasicBlock* succ1 = branchStmt->getSuccessor(0)->getBB();
319 const SVFBasicBlock* succ2 = branchStmt->getSuccessor(1)->getBB();
320 bool is_succ = (succ1 == succ || succ2 == succ);
322 assert(is_succ &&
"not a successor??");
333 return evalTestNullLike;
355 if(!test)
return false;
368 if(!test)
return false;
411 inDirVal.insert(it->getDstNode()->getValue());
413 return inDirVal.find(op0) != inDirVal.end();
421 inDirVal.insert(it->getDstNode()->getValue());
423 return inDirVal.find(op1) != inDirVal.end();
454 for (
const auto &bit: it->second)
472 assert(BB1 && BB2 &&
"expect nullptr BB here!");
524 assert(srcBB->
getParent() == dstBB->
getParent() &&
"two basic blocks are not in the same function??");
530 worklist.
push(srcBB);
533 while (!worklist.
empty())
542 return condAnd(cond, loopExitCond);
557 ") --> " <<
"succ_bb (" << succ->getName() <<
") condition: " << brCond <<
"\n");
565 ") --> " <<
"dst_bb (" << dstBB->
getName() <<
") condition: " <<
getCFCond(dstBB)
578 outs() <<
"print path condition\n";
580 for (
const auto &bbCond:
bbConds)
583 for (
const auto &cit: bbCond.second)
591 outs() << bb->
getName() <<
"-->" << succ->getName() <<
":";
622 return res == z3::unsat;
632 if (result == z3::sat || result == z3::unknown)
646 if (condition.
getExpr().num_args() == 0)
647 if (!condition.
getExpr().is_true() && !condition.
getExpr().is_false())
649 for (
u32_t i = 0; i < condition.
getExpr().num_args(); ++i)
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
const ICFGNode * getSuccessor(u32_t i) const
const ValVar * getCondition() const
Return the condition.
u32_t getPredicate() const
static u32_t maximumCxtLen
static u32_t maximumPathLen
static u64_t maximumBudget
bool push(const Data &data)
BasicBlockGraph::IDToNodeMapTy::const_iterator const_bb_iterator
void getExitBlocksOfLoop(const SVFBasicBlock *bb, BBList &exitbbs) const
const_bb_iterator begin() const
const SVFBasicBlock * getEntryBlock() const
bool isLoopHeader(const SVFBasicBlock *bb) const
const_bb_iterator end() const
const SVFBasicBlock * getExitBB() const
virtual const SVFBasicBlock * getBB() const
Return the basic block of this ICFGNode.
const ValVar * getOpVar(u32_t pos) const
Operand SVFVars.
static const Option< bool > PrintPathCond
const FunObjVar * getParent() const
const std::vector< const ICFGNode * > & getICFGNodeList() const
u32_t getBBSuccessorPos(const SVFBasicBlock *Succ)
u32_t getNumSuccessors() const
const ICFGNode * back() const
std::vector< const SVFBasicBlock * > getSuccessors() const
const CallGraph * getCallGraph()
Get CG.
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
virtual const std::string & getName() const
virtual bool isConstDataOrAggDataButNotNullPtr() const
Check if this variable represents constant data/metadata but not null pointer.
virtual void allocateForBB(const SVFBasicBlock &bb)
Allocate path condition for every basic block.
std::string dumpCond(const Condition &cond) const
Condition newCond(const ICFGNode *inst)
Allocate a new condition.
Condition evaluateTestNullLikeExpr(const BranchStmt *branchStmt, const SVFBasicBlock *succ)
Return branch condition after evaluating test null like expression.
Condition evaluateProgExit(const BranchStmt *branchStmt, const SVFBasicBlock *succ)
Return condition when there is a branch calls program exit.
Condition condOr(const Condition &lhs, const Condition &rhs)
bool isTestContainsNullAndTheValue(const CmpStmt *cmp) const
Return true if two values on the predicate are what we want.
bool isTestNullExpr(const ICFGNode *test) const
Return true if this is a test null expression.
void printPathCond()
Print out the path condition information.
bool postDominate(const SVFBasicBlock *bbKey, const SVFBasicBlock *bbValue) const
SaberCondAllocator()
Constructor.
void setBranchCond(const SVFBasicBlock *bb, const SVFBasicBlock *succ, const Condition &cond)
Get/Set a branch condition, and its terminator instruction.
virtual Condition getPHIComplementCond(const SVFBasicBlock *BB1, const SVFBasicBlock *BB2, const SVFBasicBlock *BB0)
BBCondMap bbConds
map basic block to its successors/predecessors branch conditions
Condition condNeg(const Condition &cond)
void allocate()
Perform path allocation.
static u32_t totalCondNum
vector storing z3expression
Condition condAnd(const Condition &lhs, const Condition &rhs)
Condition operations.
bool isSatisfiable(const Condition &condition)
whether condition is satisfiable
Condition getBranchCond(const SVFBasicBlock *bb, const SVFBasicBlock *succ) const
Get branch condition.
virtual Condition ComputeInterRetVFGGuard(const SVFBasicBlock *src, const SVFBasicBlock *dst, const SVFBasicBlock *retBB)
const SVFGNode * getCurEvalSVFGNode() const
Get current value for branch condition evaluation.
Condition getFalseCond() const
bool setCFCond(const SVFBasicBlock *bb, const Condition &cond)
Get/Set control-flow conditions.
void collectBBCallingProgExit(const SVFBasicBlock &bb)
Collect basic block contains program exit function call.
bool isBBCallsProgExit(const SVFBasicBlock *bb)
void extractSubConds(const Condition &condition, NodeBS &support) const
extract subexpression from a Z3 expression
Map< u32_t, Condition > CondPosMap
id to instruction map for z3
bool isEquivalentBranchCond(const Condition &lhs, const Condition &rhs) const
Whether lhs and rhs are equivalent branch conditions.
bool isEQCmp(const CmpStmt *cmp) const
Evaluate test null/not null like expressions.
bool isNECmp(const CmpStmt *cmp) const
Return true if the predicate of this compare instruction is not equal.
Condition evaluateBranchCond(const SVFBasicBlock *bb, const SVFBasicBlock *succ)
Evaluate branch conditions.
Condition evaluateLoopExitBranch(const SVFBasicBlock *bb, const SVFBasicBlock *succ)
Evaluate loop exit branch.
Condition getTrueCond() const
FIFOWorkList< const SVFBasicBlock * > CFWorkList
worklist for control-flow guard computation
bool isTestNotNullExpr(const ICFGNode *test) const
Return true if this is a test not null expression.
Condition getCFCond(const SVFBasicBlock *bb) const
FunToExitBBsMap funToExitBBsMap
map a function to all its basic blocks calling program exit
bool isNegCond(u32_t id) const
Condition getEvalBrCond(const SVFBasicBlock *bb, const SVFBasicBlock *succ)
Get a condition, evaluate the value for conditions if necessary (e.g., testNull like express).
virtual Condition ComputeInterCallVFGGuard(const SVFBasicBlock *src, const SVFBasicBlock *dst, const SVFBasicBlock *callBB)
void setNegCondInst(const Condition &condition, const ICFGNode *inst)
mark neg Z3 expression
bool dominate(const SVFBasicBlock *bbKey, const SVFBasicBlock *bbValue) const
void setCondInst(const Condition &condition, const ICFGNode *inst)
virtual Condition ComputeIntraVFGGuard(const SVFBasicBlock *src, const SVFBasicBlock *dst)
Guard Computation for a value-flow (between two basic blocks).
std::vector< Condition > conditionVec
bit vector for distinguish neg
const ICFGNode * getICFGNode() const
const z3::expr & getExpr() const
static z3::solver & getSolver()
Get z3 solver, singleton design here to make sure we only have one context.
static Z3Expr NEG(const Z3Expr &z3Expr)
compute NEG
static z3::expr nullExpr()
null expression
static z3::context & getContext()
Get z3 context, singleton design here to make sure we only have one context.
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > cast(const Y &Val)
LLVM_NODISCARD bool isa(const Y &Val)
bool isExtCall(const FunObjVar *fun)
bool isProgExitCall(const CallICFGNode *cs)
std::ostream & outs()
Overwrite llvm::outs().
LLVM_NODISCARD std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > dyn_cast(const Y &Val)
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set