308 if (inst.getArraySize())
322 llvm::Function* calledFunc = cs->getCalledFunction();
334 if (cs->arg_size() > 0)
336 const llvm::Value*
val = cs->getArgOperand(0);
345 if (cs->arg_size() > 1)
353 if (cs->arg_size() > 0)
355 const llvm::Value*
val = cs->getArgOperand(0);
376 if (
const Instruction* inst = SVFUtil::dyn_cast<Instruction>(
val))
378 switch (inst->getOpcode())
380 case Instruction::ZExt:
382 case Instruction::SExt:
384 case Instruction::BitCast:
386 case Instruction ::Trunc:
388 case Instruction::FPTrunc:
390 case Instruction::FPToUI:
392 case Instruction::FPToSI:
394 case Instruction::UIToFP:
396 case Instruction::SIToFP:
398 case Instruction::IntToPtr:
400 case Instruction::PtrToInt:
406 assert (
false &&
"Unknown cast inst!");
458 SVFUtil::cast<Instruction>(
llvmModuleSet()->getLLVMValue(inst)));
std::vector< std::pair< const ICFGNode *, s32_t > > SuccAndCondPairVec
NodeType * getGNode(NodeID id) const
Get a node.
NodeID getNullPtr() const
NodeID getValueNode(const SVFValue *V)
NodeID getVarargNode(const SVFFunction *func) const
getVarargNode - Return the unique node representing the variadic argument of a variadic function.
NodeID getReturnNode(const SVFFunction *func) const
GetReturnNode - Return the unique node representing the return value of a function.
NodeID getObjectNode(const SVFValue *V)
static LLVMModuleSet * getLLVMModuleSet()
void addToLLVMVal2SVFVarMap(const Value *val, SVFBaseNode *svfBaseNode)
ICFGNode * getICFGNode(const Instruction *inst)
Get a basic block ICFGNode.
SVFBasicBlock * getSVFBasicBlock(const BasicBlock *bb) const
LLVMContext & getContext() const
SVFValue * getSVFValue(const Value *value)
u32_t inferFieldIdxFromByteOffset(const llvm::GEPOperator *gepOp, DataLayout *dl, AccessPath &ap, APOffset idx)
Infer field index from byteoffset.
CopyStmt::CopyKind getCopyKind(const Value *val)
void sanityCheck()
Sanity check for SVFIR.
void visitLandingPadInst(LandingPadInst &I)
SVFIR * getPAG() const
Return SVFIR.
void setCurrentLocation(const Value *val, const BasicBlock *bb)
Set current basic block in order to keep track of control flow information.
NodeID addNullPtrNode()
Add NullPtr PAGNode.
void visitLoadInst(LoadInst &I)
void setCurrentLocation(const SVFValue *val, const SVFBasicBlock *bb)
SVFIRBuilder(SVFModule *mod)
Constructor.
void updateCallGraph(PTACallGraph *callgraph)
connect PAG edges based on callgraph
void addPhiStmt(NodeID res, NodeID opnd, const ICFGNode *pred)
Add Copy edge.
void addStoreEdge(NodeID src, NodeID dst)
Add Store edge.
AddrStmt * addAddrEdge(NodeID src, NodeID dst)
Add Address edge.
void visitInvokeInst(InvokeInst &II)
void handleDirectCall(CallBase *cs, const Function *F)
Handle direct call.
void addBinaryOPEdge(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
Add Copy edge.
NodeID getVarargNode(const SVFFunction *func)
getVarargNode - Return the node representing the unique variadic argument of a function.
void visitCallInst(CallInst &I)
void addLoadEdge(NodeID src, NodeID dst)
Add Load edge.
void visitGetElementPtrInst(GetElementPtrInst &I)
void visitBranchInst(BranchInst &I)
virtual void visitAllocaInst(AllocaInst &AI)
Our visit overrides.
void visitGlobal(SVFModule *svfModule)
Handle globals including (global variable and functions)
void addGepEdge(NodeID src, NodeID dst, const AccessPath &ap, bool constGep)
Add Gep edge.
void addCmpEdge(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
Add Copy edge.
void visitInsertValueInst(InsertValueInst &I)
AddrStmt * addAddrWithHeapSz(NodeID src, NodeID dst, const CallBase *cs)
Add Address edge from ext call with args like "%5 = call i8* @malloc(i64 noundef 5)".
LLVMModuleSet * llvmModuleSet()
void visitStoreInst(StoreInst &I)
void visitVAStartInst(VAStartInst &)
void addThreadForkEdge(NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
Add Thread fork edge for parameter passing.
void addGlobalBlackHoleAddrEdge(NodeID node, const ConstantExpr *int2Ptrce)
Add global black hole Address edge.
virtual ~SVFIRBuilder()
Destructor.
NodeID getObjectNode(const Value *V)
GetObject - Return the object node (stack/global/heap/function) according to a LLVM Value.
void visitCallSite(CallBase *cs)
void processCE(const Value *val)
Process constant expression.
void handleIndCall(CallBase *cs)
Handle indirect call.
void addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
Add SelectStmt.
void addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec &succs)
Add Branch statement.
virtual SVFIR * build()
Start building SVFIR here.
void visitCallBrInst(CallBrInst &I)
void visitExtractValueInst(ExtractValueInst &EVI)
AccessPath getAccessPathFromBaseNode(NodeID nodeId)
const SVFBasicBlock * curBB
Current basic block during SVFIR construction when visiting the module.
void visitSwitchInst(SwitchInst &I)
The following implementation follows ICFGBuilder::processFunBody.
void visitFreezeInst(FreezeInst &I)
void visitFenceInst(FenceInst &I)
const Value * getBaseValueForExtArg(const Value *V)
Get the base value of (i8* src and i8* dst) for external argument (e.g. memcpy(i8* dst,...
void addRetEdge(NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
Add Return edge.
virtual void handleExtCall(const CallBase *cs, const SVFFunction *svfCallee)
void addBlackHoleAddrEdge(NodeID node)
void visitInstruction(Instruction &)
Provide base case for our instruction visit.
void addNormalGepEdge(NodeID src, NodeID dst, const AccessPath &ap)
Add Offset(Gep) edge.
void visitResumeInst(ResumeInst &)
Instruction not that often.
void visitInsertElementInst(InsertElementInst &I)
const SVFValue * getCurrentValue() const
void addUnaryOPEdge(NodeID src, NodeID dst, u32_t opcode)
Add Unary edge.
void visitVAEndInst(VAEndInst &)
const SVFBasicBlock * getCurrentBB() const
virtual const Type * getBaseTypeAndFlattenedFields(const Value *V, std::vector< AccessPath > &fields, const Value *szValue)
Handle external call.
void visitPHINode(PHINode &I)
CopyStmt * addCopyEdge(NodeID src, NodeID dst, CopyStmt::CopyKind kind)
void addCallEdge(NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
Add Call edge.
void setCurrentBBAndValueForPAGEdge(PAGEdge *edge)
void visitSelectInst(SelectInst &I)
void visitVAArgInst(VAArgInst &)
void visitAtomicCmpXchgInst(AtomicCmpXchgInst &I)
void addEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind, APOffset offset=0, Instruction *cs=nullptr)
void visitCmpInst(CmpInst &I)
void visitExtractElementInst(ExtractElementInst &I)
bool computeGepOffset(const User *V, AccessPath &ap)
Compute offset of a gep instruction or gep constant expression.
void visitReturnInst(ReturnInst &I)
void visitShuffleVectorInst(ShuffleVectorInst &I)
NodeID getValueNode(const Value *V)
Get different kinds of node.
void visitCastInst(CastInst &I)
virtual void addComplexConsForExt(Value *D, Value *S, const Value *sz)
AddrStmt * addAddrWithStackArraySz(NodeID src, NodeID dst, llvm::AllocaInst &inst)
Add Address edge from allocinst with arraysize like "%4 = alloca i8, i64 3".
void visitAtomicRMWInst(AtomicRMWInst &I)
NodeID getGepValVar(const Value *val, const AccessPath &ap, const SVFType *elementType)
void visitUnreachableInst(UnreachableInst &)
void InitialGlobal(const GlobalVariable *gvar, Constant *C, u32_t offset)
void visitUnaryOperator(UnaryOperator &I)
void visitBinaryOperator(BinaryOperator &I)
void addThreadJoinEdge(NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
Add Thread join edge for parameter passing.
const SVFValue * curVal
Current Value during SVFIR construction when visiting the module.
void initialiseNodes()
Initialize nodes and edges.
NodeID getGlobalVarField(const GlobalVariable *gvar, u32_t offset, SVFType *tpy)
void addVariantGepEdge(NodeID src, NodeID dst, const AccessPath &ap)
Add Variant(Gep) edge.
void visitVACopyInst(VACopyInst &)
NodeID getReturnNode(const SVFFunction *func)
getReturnNode - Return the node representing the unique return value of a function.
GepStmt * addVariantGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Variant(Gep) edge.
CopyStmt * addCopyStmt(NodeID src, NodeID dst, CopyStmt::CopyKind type)
Add Copy edge.
RetPE * addRetPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
Add Return edge.
GepStmt * addGepStmt(NodeID src, NodeID dst, const AccessPath &ap, bool constGep)
Add Gep edge.
SVFStmt * addBlackHoleAddrStmt(NodeID node)
Set a pointer points-to black hole (e.g. int2ptr)
LoadStmt * addLoadStmt(NodeID src, NodeID dst)
Add Load edge.
GepStmt * addNormalGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Offset(Gep) edge.
CallPE * addCallPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
Add Call edge.
TDJoinPE * addThreadJoinPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
Add Thread join edge for parameter passing.
CmpStmt * addCmpStmt(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
Add Copy edge.
AddrStmt * addAddrStmt(NodeID src, NodeID dst)
Add an edge into SVFIR.
UnaryOPStmt * addUnaryOPStmt(NodeID src, NodeID dst, u32_t opcode)
Add Unary edge.
NodeID addConstantNullPtrValNode(const SVFValue *curInst, const NodeID i, const ICFGNode *icfgNode)
TDForkPE * addThreadForkPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
Add Thread fork edge for parameter passing.
BinaryOPStmt * addBinaryOPStmt(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
Add Copy edge.
StoreStmt * addStoreStmt(NodeID src, NodeID dst, const ICFGNode *val)
Add Store edge.
PhiStmt * addPhiStmt(NodeID res, NodeID opnd, const ICFGNode *pred)
Add phi node information.
SelectStmt * addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
Add SelectStmt.
BranchStmt * addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec &succs)
Add BranchStmt.
std::string wrnMsg(const std::string &msg)
Returns warning message by converting a string into yellow string output.
llvm::DataLayout DataLayout
llvm::GlobalVariable GlobalVariable
llvm::VACopyInst VACopyInst
llvm::BasicBlock BasicBlock
llvm::UnaryOperator UnaryOperator
llvm::AllocaInst AllocaInst
llvm::SwitchInst SwitchInst
llvm::AtomicRMWInst AtomicRMWInst
llvm::InsertValueInst InsertValueInst
llvm::InvokeInst InvokeInst
llvm::AtomicCmpXchgInst AtomicCmpXchgInst
llvm::FenceInst FenceInst
llvm::ShuffleVectorInst ShuffleVectorInst
llvm::InsertElementInst InsertElementInst
llvm::Instruction Instruction
llvm::UnreachableInst UnreachableInst
llvm::ResumeInst ResumeInst
llvm::Value Value
LLVM Basic classes.
llvm::ConstantPointerNull ConstantPointerNull
llvm::ConstantExpr ConstantExpr
llvm::IRBuilder IRBuilder
llvm::FreezeInst FreezeInst
llvm::BinaryOperator BinaryOperator
llvm::StoreInst StoreInst
llvm::SelectInst SelectInst
llvm::VAArgInst VAArgInst
llvm::GetElementPtrInst GetElementPtrInst
llvm::CallBrInst CallBrInst
llvm::ReturnInst ReturnInst
llvm::BranchInst BranchInst
llvm::ExtractValueInst ExtractValueInst
llvm::VAStartInst VAStartInst
llvm::VAEndInst VAEndInst
llvm::LandingPadInst LandingPadInst
llvm::ExtractElementInst ExtractElementInst
llvm::LLVMContext LLVMContext