Skip to content

Commit 853ea5d

Browse files
Add code to populate the basic block predecessors
1 parent 51a3213 commit 853ea5d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/blocks/basic_blocks.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,12 @@ std::vector<std::shared_ptr<basic_block>> generate_basic_blocks(block::stmt_bloc
153153
}
154154
}
155155

156+
// step 5: populate the predecessors
157+
for (auto bb: return_list) {
158+
for (auto succ: bb->successor) {
159+
succ->predecessor.push_back(bb);
160+
}
161+
}
162+
156163
return return_list;
157164
}

src/blocks/loop_finder.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ void loop_finder::visit(stmt_block::Ptr a) {
133133

134134
std::cout << "++++++ basic blocks ++++++ \n";
135135
for (auto bb: BBs) {
136-
std::cout << bb->name << ":" << "\n";
136+
std::cout << bb->name << ":" << " ; ";
137+
for (auto pred: bb->predecessor) {
138+
std::cout << pred->name << ", ";
139+
}
140+
std::cout << "\n";
137141
if (bb->branch_expr) {
138142
std::cout << " ";
139143
bb->branch_expr->dump(std::cout, 0);

0 commit comments

Comments
 (0)