diff --git a/svf-llvm/include/SVF-LLVM/LLVMModule.h b/svf-llvm/include/SVF-LLVM/LLVMModule.h index fa812a9d8..cab9d2835 100644 --- a/svf-llvm/include/SVF-LLVM/LLVMModule.h +++ b/svf-llvm/include/SVF-LLVM/LLVMModule.h @@ -57,7 +57,6 @@ class LLVMModuleSet typedef Map LLVMFun2SVFFunMap; typedef Map LLVMFun2CallGraphNodeMap; typedef Map LLVMBB2SVFBBMap; - typedef Map SVFBB2LLVMBBMap; typedef Map LLVMInst2SVFInstMap; typedef Map LLVMArgument2SVFArgumentMap; typedef Map LLVMConst2SVFConstMap; @@ -94,7 +93,6 @@ class LLVMModuleSet LLVMFun2SVFFunMap LLVMFunc2SVFFunc; ///< Map an LLVM Function to an SVF Function LLVMFun2CallGraphNodeMap LLVMFunc2CallGraphNode; ///< Map an LLVM Function to an CallGraph Node LLVMBB2SVFBBMap LLVMBB2SVFBB; - SVFBB2LLVMBBMap SVFBB2LLVMBB; LLVMInst2SVFInstMap LLVMInst2SVFInst; LLVMArgument2SVFArgumentMap LLVMArgument2SVFArgument; LLVMConst2SVFConstMap LLVMConst2SVFConst; @@ -183,7 +181,7 @@ class LLVMModuleSet inline void addBasicBlockMap(const BasicBlock* bb, SVFBasicBlock* svfBB) { LLVMBB2SVFBB[bb] = svfBB; - SVFBB2LLVMBB[svfBB] = bb; + SVFBaseNode2LLVMValue[svfBB] = bb; } inline void addInstructionMap(const Instruction* inst, SVFInstruction* svfInst) @@ -249,19 +247,9 @@ class LLVMModuleSet const Value* getLLVMValue(const SVFBaseNode* value) const { - if (SVFUtil::isa(value)) - { - const SVFBasicBlock* bb = SVFUtil::cast(value); - SVFBB2LLVMBBMap::const_iterator it = SVFBB2LLVMBB.find(bb); - assert(it!=SVFBB2LLVMBB.end() && "can't find corresponding llvm value!"); - return it->second; - } - else - { - SVFBaseNode2LLVMValueMap ::const_iterator it = SVFBaseNode2LLVMValue.find(value); - assert(it != SVFBaseNode2LLVMValue.end() && "can't find corresponding llvm value!"); - return it->second; - } + SVFBaseNode2LLVMValueMap ::const_iterator it = SVFBaseNode2LLVMValue.find(value); + assert(it != SVFBaseNode2LLVMValue.end() && "can't find corresponding llvm value!"); + return it->second; } inline CallGraphNode* getCallGraphNode(const Function* fun) const @@ -285,13 +273,6 @@ class LLVMModuleSet return it->second; } - const BasicBlock* getLLVMBasicBlock(const SVFBasicBlock* bb) const - { - SVFBB2LLVMBBMap::const_iterator it = SVFBB2LLVMBB.find(bb); - assert(it!=SVFBB2LLVMBB.end() && "LLVM BasicBlock not found!"); - return it->second; - } - inline SVFInstruction* getSVFInstruction(const Instruction* inst) const { LLVMInst2SVFInstMap::const_iterator it = LLVMInst2SVFInst.find(inst); diff --git a/svf-llvm/lib/ObjTypeInference.cpp b/svf-llvm/lib/ObjTypeInference.cpp index 1308fe827..bc1c730f9 100644 --- a/svf-llvm/lib/ObjTypeInference.cpp +++ b/svf-llvm/lib/ObjTypeInference.cpp @@ -586,7 +586,7 @@ Set &ObjTypeInference::bwfindAllocOfVar(const Value *var) if (!callee->isDeclaration()) { const SVFFunction *svfFunc = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(callee); - const BasicBlock* exitBB = LLVMModuleSet::getLLVMModuleSet()->getLLVMBasicBlock(svfFunc->getExitBB()); + const BasicBlock* exitBB = SVFUtil::dyn_cast(LLVMModuleSet::getLLVMModuleSet()->getLLVMValue(svfFunc->getExitBB())); const Value *pValue = &exitBB->back(); const auto *retInst = SVFUtil::dyn_cast(pValue); ABORT_IFNOT(retInst && retInst->getReturnValue(), "not return inst?"); @@ -893,7 +893,7 @@ Set &ObjTypeInference::bwFindAllocOrClsNameSources(const Value *s if (!callee->isDeclaration()) { const SVFFunction *svfFunc = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(callee); - const BasicBlock* exitBB = LLVMModuleSet::getLLVMModuleSet()->getLLVMBasicBlock(svfFunc->getExitBB()); + const BasicBlock* exitBB = SVFUtil::dyn_cast(LLVMModuleSet::getLLVMModuleSet()->getLLVMValue(svfFunc->getExitBB())); const Value *pValue = &exitBB->back(); const auto *retInst = SVFUtil::dyn_cast(pValue); ABORT_IFNOT(retInst && retInst->getReturnValue(), "not return inst?"); diff --git a/svf/include/SVFIR/SVFValue.h b/svf/include/SVFIR/SVFValue.h index 297508935..5fa409212 100644 --- a/svf/include/SVFIR/SVFValue.h +++ b/svf/include/SVFIR/SVFValue.h @@ -418,6 +418,7 @@ class SVFFunction : public SVFValue inline const SVFBasicBlock* getEntryBlock() const { assert(hasBasicBlock() && "function does not have any Basicblock, external function?"); + assert(bbGraph->begin()->second->getInEdges().size() == 0 && "the first basic block is not entry block"); return bbGraph->begin()->second; }