55 for (Module::const_iterator F = M.begin(), E = M.end(); F != E; ++F)
58 if (fun->isDeclaration())
68 for (Module::const_iterator F = M.begin(), E = M.end(); F != E; ++F)
71 if (fun->isDeclaration())
89 for (
const auto& bb: *fun)
91 for (
const auto& inst: bb)
95 assert(
visited.count(&inst) &&
"inst never visited");
96 assert(
hasICFGNode(&inst) &&
"icfgnode not created");
106 const Instruction* entryInst = &((fun->getEntryBlock()).front());
112 insts.push_back(entryInst);
113 for (InstVec::const_iterator nit = insts.begin(), enit = insts.end();
133 for (
const auto& bb : *fun)
140 worklist.
push(&bb.front());
151 while (!worklist.
empty())
163 for (InstVec::const_iterator nit = nextInsts.begin(), enit =
164 nextInsts.end(); nit != enit; ++nit)
183 srcNode = retICFGNode;
188 assert(branchID <= 1 &&
"if/else has more than two branches?");
189 if(br->isConditional())
190 icfg->addConditionalIntraEdge(srcNode, dstNode, 1 - branchID);
192 icfg->addIntraEdge(srcNode, dstNode);
200 if (condVal && condVal->getBitWidth() <= 64)
202 icfg->addConditionalIntraEdge(srcNode, dstNode,val);
205 icfg->addIntraEdge(srcNode, dstNode);
220 for (
const auto& bb : *f)
222 for (
const auto& inst : bb)
243 assert(
llvmModuleSet()->getCallBlock(inst)==
nullptr &&
"duplicate CallICFGNode");
247 auto called_llvmval = cb->getCalledOperand()->stripPointerCasts();
266 assert(
llvmModuleSet()->getRetBlock(inst)==
nullptr &&
"duplicate RetICFGNode");
291 icfg->addIntraEdge(callICFGNode, retBlockNode);
298 icfg->addCallEdge(callICFGNode, calleeEntryNode);
299 icfg->addRetEdge(calleeExitNode, retBlockNode);
305 icfg->addIntraEdge(callICFGNode, retBlockNode);
321 icfg->addICFGEdge(intraEdge);
347 assert (node==
nullptr &&
"no IntraICFGNode for this instruction?");
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
bool push(const Data &data)
const SVFFunctionType * getFunctionType() const
Returns the FunctionType.
SVFLoopAndDomInfo * getLoopAndDomInfo() const
ICFGNode * getICFGNode(const Instruction *inst)
FunEntryICFGNode * addFunEntryBlock(const Function *fun)
void connectGlobalToProgEntry()
FunEntryICFGNode * getFunEntryICFGNode(const Function *fun)
get a function entry node
FIFOWorkList< const Instruction * > WorkList
FunExitICFGNode * getFunExitICFGNode(const Function *fun)
get a function exit node
IntraICFGNode * addIntraBlockICFGNode(const Instruction *inst)
Add and get IntraBlock ICFGNode.
CallICFGNode * getCallICFGNode(const Instruction *cs)
get a call node
std::vector< const Instruction * > InstVec
LLVMModuleSet * llvmModuleSet()
void processUnreachableFromEntry(const Function *fun, WorkList &worklist)
InterICFGNode * addInterBlockICFGNode(const Instruction *inst)
Add/Get an inter block ICFGNode.
bool hasICFGNode(const Instruction *inst)
void processFunBody(WorkList &worklist)
GlobalICFGNode * getGlobalICFGNode() const
void checkICFGNodesVisited(const Function *fun)
void processFunEntry(const Function *fun, WorkList &worklist)
FunExitICFGNode * addFunExitBlock(const Function *fun)
ICFGNode * addBlockICFGNode(const Instruction *inst)
Add/Get a basic block ICFGNode.
RetICFGNode * getRetICFGNode(const Instruction *cs)
get a return node
void addICFGInterEdges(const Instruction *cs, const Function *callee)
Create edges between ICFG nodes across functions.
void processFunExit(const Function *fun)
IntraICFGNode * getIntraBlock(const Instruction *inst)
const FunObjVar * getFunObjVar(const Function *fun) const
SVFBasicBlock * getSVFBasicBlock(const BasicBlock *bb)
void addInstructionMap(const Instruction *inst, CallICFGNode *svfInst)
FunToFunEntryNodeMapTy FunToFunEntryNodeMap
map a function to its FunExitICFGNode
FunToFunExitNodeMapTy FunToFunExitNodeMap
map a function to its FunEntryICFGNode
bool isUnreachable(const SVFBasicBlock *bb) const
bool isIntrinsicInst(const Instruction *inst)
Return true if it is an intrinsic instruction.
bool isCallSite(const Instruction *inst)
Whether an instruction is a call or invoke instruction.
std::pair< s64_t, u64_t > getIntegerValue(const ConstantInt *intValue)
void getNextInsts(const Instruction *curInst, std::vector< const Instruction * > &instList)
Get the next instructions following control flow.
const Function * getProgEntryFunction(Module &module)
Get program entry function from module.
const Function * getCallee(const CallBase *cs)
bool isNonInstricCallSite(const Instruction *inst)
Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls.
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)
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::string getFunNameOfVCallSite(const CallBase *cs)
s32_t getVCallIdx(const CallBase *cs)
bool isVirtualCallSite(const CallBase *cs)
llvm::BasicBlock BasicBlock
llvm::SwitchInst SwitchInst
llvm::Instruction Instruction
llvm::BranchInst BranchInst
llvm::ConstantInt ConstantInt