Skip to content

Commit

Permalink
remove SVFFunction::getBasicBlockList(), move addBasicBlock to BasicB…
Browse files Browse the repository at this point in the history
…lockGraph. And some related chages
  • Loading branch information
bjjwwang committed Jan 26, 2025
1 parent d97854b commit 66508f7
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion svf-llvm/include/SVF-LLVM/LLVMModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class LLVMModuleSet

const Value* getLLVMValue(const SVFBaseNode* value) const
{
if (value->getNodeKind() == SVFBaseNode::BasicBlockKd)
if (SVFUtil::isa<SVFBasicBlock>(value))
{
const SVFBasicBlock* bb = SVFUtil::cast<SVFBasicBlock>(value);

Check warning on line 254 in svf-llvm/include/SVF-LLVM/LLVMModule.h

View check run for this annotation

Codecov / codecov/patch

svf-llvm/include/SVF-LLVM/LLVMModule.h#L254

Added line #L254 was not covered by tests
SVFBB2LLVMBBMap::const_iterator it = SVFBB2LLVMBB.find(bb);
Expand Down
2 changes: 1 addition & 1 deletion svf-llvm/lib/LLVMModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ void LLVMModuleSet::createSVFFunction(const Function* func)

for (const BasicBlock& bb : *func)
{
SVFBasicBlock* svfBB = svfFunc->addBasicBlock(bb.getName().str());
SVFBasicBlock* svfBB = bbGraph->addBasicBlock(bb.getName().str());
addBasicBlockMap(&bb, svfBB);
for (const Instruction& inst : bb)
{
Expand Down
10 changes: 10 additions & 0 deletions svf/include/Graphs/BasicBlockG.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ class SVFBasicBlock : public GenericBasicBlockNodeTy

}

static inline bool classof(const SVFBaseNode* node)
{
return node->getNodeKind() == SVFBaseNode::BasicBlockKd;
}

static inline bool classof(const SVFBasicBlock* node)
{
return true;
}

//@{
friend OutStream &operator<<(OutStream &o, const SVFBasicBlock&node)
{
Expand Down
16 changes: 0 additions & 16 deletions svf/include/SVFIR/SVFValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,6 @@ class SVFFunction : public SVFValue
callGraphNode = cgn;
}


inline SVFBasicBlock* addBasicBlock(const std::string& bbName) {
SVFBasicBlock* bb = bbGraph->addBasicBlock(bbName);
return bb;
}

inline void addArgument(SVFArgument* arg)
{
allArgs.push_back(arg);
Expand Down Expand Up @@ -457,16 +451,6 @@ class SVFFunction : public SVFValue
return bbGraph->end();
}

inline std::vector<const SVFBasicBlock*> getBasicBlockList() const
{
std::vector<const SVFBasicBlock*> blockList;
blockList.reserve(bbGraph->getTotalNodeNum());
std::transform(bbGraph->begin(), bbGraph->end(), std::back_inserter(blockList),
[](const BasicBlockGraph::IDToNodeMapTy::value_type& pair) {
return pair.second;
});
return blockList;
}

inline const std::vector<const SVFBasicBlock*>& getReachableBBs() const
{
Expand Down
3 changes: 2 additions & 1 deletion svf/lib/MTA/LockAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ void LockAnalysis::collectLockUnlocksites()

for (const SVFFunction* F : tct->getSVFModule()->getFunctionSet())
{
for (const SVFBasicBlock* bb : F->getBasicBlockList())
for (auto it : *F)
{
const SVFBasicBlock* bb = it.second;
for (const ICFGNode* icfgNode : bb->getICFGNodeList())
{
if (isa<CallICFGNode>(icfgNode) && tcg->getThreadAPI()->isTDRelease(cast<CallICFGNode>(icfgNode)))
Expand Down
3 changes: 2 additions & 1 deletion svf/lib/MTA/MHP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ void MHP::updateNonCandidateFunInterleaving()
{
const CallStrCxt& curCxt = cts.getContext();

for (const SVFBasicBlock* svfbb : fun->getBasicBlockList())
for (auto it : *fun)
{
const SVFBasicBlock* svfbb = it.second;
for (const ICFGNode* curNode : svfbb->getICFGNodeList())
{
if (curNode == entryNode)
Expand Down
3 changes: 2 additions & 1 deletion svf/lib/MTA/MTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ void MTA::detect(SVFModule* module)
for (const SVFFunction* F : module->getFunctionSet())
{
// collect and create symbols inside the function body
for (const SVFBasicBlock* svfbb : F->getBasicBlockList())
for (auto it : *F)
{
const SVFBasicBlock* svfbb = it.second;
for (const ICFGNode* icfgNode : svfbb->getICFGNodeList())
{
for(const SVFStmt* stmt : pag->getSVFStmtList(icfgNode))
Expand Down
9 changes: 6 additions & 3 deletions svf/lib/Util/CallGraphBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ CallGraph* CallGraphBuilder::buildSVFIRCallGraph(SVFModule* svfModule)

for (const auto& item : *callgraph)
{
for (const SVFBasicBlock* svfbb : (item.second)->getFunction()->getBasicBlockList())
for (auto it : *(item.second)->getFunction())
{
const SVFBasicBlock* svfbb = it.second;
for (const ICFGNode* inst : svfbb->getICFGNodeList())
{
if (SVFUtil::isNonInstricCallSite(inst))
Expand Down Expand Up @@ -80,8 +81,9 @@ ThreadCallGraph* CallGraphBuilder::buildThreadCallGraph()
ThreadAPI* tdAPI = ThreadAPI::getThreadAPI();
for (const auto& item: *svfirCallGraph)
{
for (const SVFBasicBlock* svfbb : (item.second)->getFunction()->getBasicBlockList())
for (auto it : *(item.second)->getFunction())
{
const SVFBasicBlock* svfbb = it.second;
for (const ICFGNode* inst : svfbb->getICFGNodeList())
{
if (SVFUtil::isa<CallICFGNode>(inst) && tdAPI->isTDFork(SVFUtil::cast<CallICFGNode>(inst)))
Expand All @@ -105,8 +107,9 @@ ThreadCallGraph* CallGraphBuilder::buildThreadCallGraph()
// record join sites
for (const auto& item: *svfirCallGraph)
{
for (const SVFBasicBlock* svfbb : (item.second)->getFunction()->getBasicBlockList())
for (auto it : *(item.second)->getFunction())
{
const SVFBasicBlock* svfbb = it.second;
for (const ICFGNode* node : svfbb->getICFGNodeList())
{
if (SVFUtil::isa<CallICFGNode>(node) && tdAPI->isTDJoin(SVFUtil::cast<CallICFGNode>(node)))
Expand Down

0 comments on commit 66508f7

Please sign in to comment.