30#ifndef PATHALLOCATOR_H_
31#define PATHALLOCATOR_H_
75 return std::to_string(
vmsize) +
"KB";
77 return "cannot read memory usage";
153 assert(
funcEq &&
"two basicblocks should be in the same function!");
163 assert(
funcEq &&
"two basicblocks should be in the same function!");
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
void allocate(const SVFModule *module)
Perform path allocation.
virtual ~SaberCondAllocator()
Destructor.
virtual void allocateForBB(const SVFBasicBlock &bb)
Allocate path condition for every basic block.
SVFGNodeToSVFGNodeSetMap removedSUVFEdges
a counter for fresh condition
std::string dumpCond(const Condition &cond) const
Condition newCond(const ICFGNode *inst)
Allocate a new condition.
Map< const SVFGNode *, Set< const SVFGNode * > > SVFGNodeToSVFGNodeSetMap
Map< const SVFFunction *, BasicBlockSet > FunToExitBBsMap
map a function to all its basic blocks calling program exit
bool isAllPathReachable(Condition &condition)
whether condition is satisfiable for all possible boolean guards
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
NodeBS negConds
key: z3 expression id, value: instruction
Set< const SVFBasicBlock * > BasicBlockSet
map bb to a Condition
const SVFGNode * curEvalSVFGNode
current llvm value to evaluate branch condition when computing guards
SaberCondAllocator()
Constructor.
void setBranchCond(const SVFBasicBlock *bb, const SVFBasicBlock *succ, const Condition &cond)
Get/Set a branch condition, and its terminator instruction.
Map< const SVFBasicBlock *, CondPosMap > BBCondMap
void destroy()
Release memory.
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)
BBToCondMap bbToCondMap
map a basic block to its path condition starting from root
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.
Map< u32_t, const ICFGNode * > IndexToTermInstMap
z3 condition
NodeBS exactCondElem(const Condition &cond)
Iterator every element of the 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.
std::string getMemUsage()
Statistics.
Condition getCFCond(const SVFBasicBlock *bb) const
const ICFGNode * getCondInst(u32_t id) const
Get/Set instruction based on Z3 expression id.
FunToExitBBsMap funToExitBBsMap
map a function to all its basic blocks calling program exit
bool isNegCond(u32_t id) const
SVFGNodeToSVFGNodeSetMap & getRemovedSUVFEdges()
Map< const SVFBasicBlock *, Condition > BBToCondMap
map a basic block to its condition during control-flow guard computation
void setCurEvalSVFGNode(const SVFGNode *node)
Set current value for branch condition evaluation.
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)
IndexToTermInstMap idToTermInstMap
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
bool test(unsigned Idx) const
static Z3Expr AND(const Z3Expr &lhs, const Z3Expr &rhs)
compute AND, used for branch condition
static std::string dumpStr(const Z3Expr &z3Expr)
output Z3 expression as a string
static Z3Expr NEG(const Z3Expr &z3Expr)
compute NEG
static Z3Expr getTrueCond()
Return the unique true condition.
static Z3Expr OR(const Z3Expr &lhs, const Z3Expr &rhs)
compute OR, used for branch condition
static Z3Expr getFalseCond()
Return the unique false condition.
bool getMemoryUsageKB(u32_t *vmrss_kb, u32_t *vmsize_kb)
Get memory usage from system file. Return TRUE if succeed.
llvm::IRBuilder IRBuilder