@@ -13,6 +13,7 @@ basic_block::cfg_block generate_basic_blocks(block::stmt_block::Ptr ast) {
13
13
for (auto st: ast->stmts ) {
14
14
auto bb = std::make_shared<basic_block>(std::to_string (basic_block_count));
15
15
bb->parent = st;
16
+ // bb->ast_to_basic_block_map[bb->parent] = bb;
16
17
bb->ast_index = ast_index_counter++;
17
18
bb->ast_depth = 0 ;
18
19
work_list.push_back (bb);
@@ -40,6 +41,7 @@ basic_block::cfg_block generate_basic_blocks(block::stmt_block::Ptr ast) {
40
41
for (auto st: stmt_block_->stmts ) {
41
42
stmt_block_list.push_back (std::make_shared<basic_block>(std::to_string (basic_block_count++)));
42
43
stmt_block_list.back ()->parent = st;
44
+ // stmt_block_list.back()->ast_to_basic_block_map[bb->parent] = stmt_block_list.back();
43
45
stmt_block_list.back ()->ast_index = ast_index_counter++;
44
46
stmt_block_list.back ()->ast_depth = bb->ast_depth + 1 ;
45
47
}
@@ -79,6 +81,8 @@ basic_block::cfg_block generate_basic_blocks(block::stmt_block::Ptr ast) {
79
81
auto exit_bb = std::make_shared<basic_block>(" exit" + std::to_string (basic_block_count));
80
82
// assign it a empty stmt_block as parent
81
83
exit_bb->parent = std::make_shared<stmt_block>();
84
+ // add mapping in ast to bb map
85
+ // exit_bb->ast_to_basic_block_map[exit_bb->parent] = exit_bb;
82
86
// set the ast depth of the basic block
83
87
exit_bb->ast_depth = bb->ast_depth ;
84
88
// check if this is the last block, if yes the successor will be empty
@@ -98,6 +102,8 @@ basic_block::cfg_block generate_basic_blocks(block::stmt_block::Ptr ast) {
98
102
auto then_bb = std::make_shared<basic_block>(std::to_string (++basic_block_count));
99
103
// set the parent of this block as the then stmts
100
104
then_bb->parent = if_stmt_->then_stmt ;
105
+ // add mapping in ast to bb map
106
+ // then_bb->ast_to_basic_block_map[then_bb->parent] = then_bb;
101
107
// set the ast depth of the basic block
102
108
then_bb->ast_depth = bb->ast_depth ;
103
109
// set the successor of this block to be the exit block
@@ -112,6 +118,8 @@ basic_block::cfg_block generate_basic_blocks(block::stmt_block::Ptr ast) {
112
118
auto else_bb = std::make_shared<basic_block>(std::to_string (++basic_block_count));
113
119
// set the parent of this block as the else stmts
114
120
else_bb->parent = if_stmt_->else_stmt ;
121
+ // add mapping in ast to bb map
122
+ // else_bb->ast_to_basic_block_map[else_bb->parent] = else_bb;
115
123
// set the ast depth of the basic block
116
124
else_bb->ast_depth = bb->ast_depth ;
117
125
// set the successor of this block to be the exit block
0 commit comments