@@ -8278,7 +8278,9 @@ interp_reorder_bblocks (TransformData *td)
82788278
82798279 for (bb = td -> entry_bb ; bb != NULL ; bb = bb -> next_bb ) {
82808280 InterpInst * first = interp_first_ins (bb );
8281- if (first && MINT_IS_CONDITIONAL_BRANCH (first -> opcode )) {
8281+ if (!first )
8282+ continue ;
8283+ if (MINT_IS_CONDITIONAL_BRANCH (first -> opcode )) {
82828284 // This means this bblock has a single instruction, the conditional branch
82838285 int i = 0 ;
82848286 int lookup_var2 = (mono_interp_op_dregs [first -> opcode ] > 1 ) ? first -> sregs [1 ] : -1 ;
@@ -8329,6 +8331,36 @@ interp_reorder_bblocks (TransformData *td)
83298331 i ++ ;
83308332 }
83318333 }
8334+ } else if (first -> opcode == MINT_BR ) {
8335+ // All bblocks jumping into this bblock can jump directly into the br target
8336+ int i = 0 ;
8337+ while (i < bb -> in_count ) {
8338+ InterpBasicBlock * in_bb = bb -> in_bb [i ];
8339+ InterpInst * last_ins = interp_last_ins (in_bb );
8340+ if (last_ins && (MINT_IS_CONDITIONAL_BRANCH (last_ins -> opcode ) ||
8341+ MINT_IS_UNCONDITIONAL_BRANCH (last_ins -> opcode )) &&
8342+ last_ins -> info .target_bb == bb ) {
8343+ InterpBasicBlock * target_bb = first -> info .target_bb ;
8344+ last_ins -> info .target_bb = target_bb ;
8345+ interp_unlink_bblocks (in_bb , bb );
8346+ interp_link_bblocks (td , in_bb , target_bb );
8347+ if (td -> verbose_level ) {
8348+ GString * bb_info = get_interp_bb_links (bb );
8349+ GString * in_bb_info = get_interp_bb_links (in_bb );
8350+ GString * target_bb_info = get_interp_bb_links (target_bb );
8351+ g_print ("Propagated target bb BB%d into BB%d\n" , target_bb -> index , in_bb -> index );
8352+ g_print ("\tBB%d: %s\n" , bb -> index , bb_info -> str );
8353+ g_print ("\tBB%d: %s\n" , in_bb -> index , in_bb_info -> str );
8354+ g_print ("\tBB%d: %s\n" , target_bb -> index , target_bb_info -> str );
8355+ g_string_free (bb_info , TRUE);
8356+ g_string_free (in_bb_info , TRUE);
8357+ g_string_free (target_bb_info , TRUE);
8358+ }
8359+ i = 0 ;
8360+ } else {
8361+ i ++ ;
8362+ }
8363+ }
83328364 }
83338365 }
83348366}
0 commit comments