Skip to content

Commit

Permalink
Final merge for version 15.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
rseac committed Oct 8, 2024
1 parent 74a5b9d commit f014def
Showing 1 changed file with 1 addition and 108 deletions.
109 changes: 1 addition & 108 deletions src/cfg/SplitCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ SplitCFG::SplitCFG(clang::ASTContext& context)

SplitCFG::SplitCFG(clang::ASTContext& context,
const clang::CXXMethodDecl* method)
: context_{context},
: context_{context},
next_state_count_{0},
popping_{false},
outter_top_(nullptr),
Expand All @@ -1176,112 +1176,6 @@ std::map<SplitCFGBlock*, SplitCFGBlock*> SplitCFG::getConfluenceBlocks() const {
return cop_;
}

std::set<SplitCFGBlock*> SplitCFG::identifySkipBlocks() {
llvm::dbgs() << "########### BFS Identify confluence blocks ############ \n";
std::queue<SplitCFGBlock*> Q{};
std::set<SplitCFGBlock*> discovered{};

SplitCFGBlock* v{outter_top_};
SplitCFGBlock* target = cop_[outter_top_];
llvm::dbgs() << "Outter ternop is BB" << outter_top->getBlockID() << " and confluence block is BB" << target->getBlockID() << "\n";
// if (!source) v = sccfg_[cfg_->getEntry().getBlockID()];
// else v = source;

discovered.insert(v);

Q.push(v);

while (!Q.empty()) {
v = Q.front();
Q.pop();
llvm::dbgs() << "visited " << v->getBlockID() << "\n";

for (auto succ : v->getCFGBlock()->succs()) {
if (succ && (v->getBlockID() != target->getBlockID())) {
auto blk{sccfg_[succ->getBlockID()]};
if (discovered.find(blk) == discovered.end()) {
discovered.insert(blk);
Q.push(blk);
}
}
}
}

llvm::dbgs() << "Discovered\n";
for (auto disc : discovered ) {
llvm::dbgs() << disc->getBlockID() <<" ";

}
return discovered;
}

void SplitCFG::identifyConfluenceBlocks() {
llvm::dbgs() << "########### Identify confluence blocks ############ \n";

// ConditionalOperator block => Confluence Block
// std::map<SplitFGBlock*, SplitCFGBlock*> cop_;
std::vector<SplitCFGBlock*> ternops;

std::vector<SplitCFGBlock*> S{};
std::set<SplitCFGBlock*> discovered{};
// Do DFS whenever you reach a conditional operator block.
SplitCFGBlock* v = sccfg_[cfg_->getEntry().getBlockID()];

SplitCFGBlock* outter{nullptr};

S.push_back(v);
while (!S.empty()) {
v = S.back();
S.pop_back();
if (discovered.find(v) == discovered.end()) {
discovered.insert(v);
llvm::dbgs() << "visited " << v->getBlockID() << "\n";

// Found ConditionalOperator
auto stmt{v->getCFGBlock()->getTerminatorStmt()};
if (stmt && clang::dyn_cast<clang::ConditionalOperator>(stmt)) {
llvm::dbgs() << "Found a TERNARY OP block\n";

if (!outter) outter = v;

cop_.insert(std::make_pair(v, nullptr));
ternops.push_back(v);

} else if (ternops.size() > 0) {
auto top_cop{ternops.back()};
// Successor is the confluence
if (v->getCFGBlock()->succ_size() == 1) {
auto conf_blk{*v->getCFGBlock()->succ_begin()};
llvm::dbgs() << "Found confluence block of " << conf_blk->getBlockID()
<< " from block " << v->getBlockID() << " of "
<< top_cop->getBlockID() << "\n";
cop_[top_cop] = sccfg_[conf_blk->getBlockID()];

conf_blk->dump();
ternops.pop_back();
}
}

for (auto next_v : v->getCFGBlock()->succs()) {
if (next_v) S.push_back(sccfg_[next_v->getBlockID()]);
}
}
}
// Print the cop map.
llvm::dbgs() << "Block ids for COP ";
for (auto& co : cop_) {
llvm::dbgs() << co.first->getBlockID() << " :=> " << co.second->getBlockID()
<< " ; ";
}
llvm::dbgs() << "\n";

outter_top = outter;
}

std::map<SplitCFGBlock*, SplitCFGBlock*> SplitCFG::getConfluenceBlocks() const {
return cop_;
}

std::set<SplitCFGBlock*> SplitCFG::identifySkipBlocks() {
llvm::dbgs() << "########### BFS Identify confluence blocks ############ \n";
std::queue<SplitCFGBlock*> Q{};
Expand Down Expand Up @@ -1385,4 +1279,3 @@ void SplitCFG::identifyConfluenceBlocks() {

outter_top_ = outter;
}
>>>>>>> scratchllnl

0 comments on commit f014def

Please sign in to comment.