@@ -13,6 +13,7 @@ basic_block::cfg_block generate_basic_blocks(block::stmt_block::Ptr ast) {
1313 for (auto st: ast->stmts ) {
1414 auto bb = std::make_shared<basic_block>(std::to_string (basic_block_count));
1515 bb->parent = st;
16+ // bb->ast_to_basic_block_map[bb->parent] = bb;
1617 bb->ast_index = ast_index_counter++;
1718 bb->ast_depth = 0 ;
1819 work_list.push_back (bb);
@@ -40,6 +41,7 @@ basic_block::cfg_block generate_basic_blocks(block::stmt_block::Ptr ast) {
4041 for (auto st: stmt_block_->stmts ) {
4142 stmt_block_list.push_back (std::make_shared<basic_block>(std::to_string (basic_block_count++)));
4243 stmt_block_list.back ()->parent = st;
44+ // stmt_block_list.back()->ast_to_basic_block_map[bb->parent] = stmt_block_list.back();
4345 stmt_block_list.back ()->ast_index = ast_index_counter++;
4446 stmt_block_list.back ()->ast_depth = bb->ast_depth + 1 ;
4547 }
@@ -79,6 +81,8 @@ basic_block::cfg_block generate_basic_blocks(block::stmt_block::Ptr ast) {
7981 auto exit_bb = std::make_shared<basic_block>(" exit" + std::to_string (basic_block_count));
8082 // assign it a empty stmt_block as parent
8183 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;
8286 // set the ast depth of the basic block
8387 exit_bb->ast_depth = bb->ast_depth ;
8488 // 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) {
98102 auto then_bb = std::make_shared<basic_block>(std::to_string (++basic_block_count));
99103 // set the parent of this block as the then stmts
100104 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;
101107 // set the ast depth of the basic block
102108 then_bb->ast_depth = bb->ast_depth ;
103109 // 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) {
112118 auto else_bb = std::make_shared<basic_block>(std::to_string (++basic_block_count));
113119 // set the parent of this block as the else stmts
114120 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;
115123 // set the ast depth of the basic block
116124 else_bb->ast_depth = bb->ast_depth ;
117125 // set the successor of this block to be the exit block
0 commit comments