@@ -3210,7 +3210,7 @@ interp_field_from_token (MonoMethod *method, guint32 token, MonoClass **klass, M
32103210}
32113211
32123212static InterpBasicBlock *
3213- get_bb (TransformData * td , unsigned char * ip )
3213+ get_bb (TransformData * td , unsigned char * ip , gboolean make_list )
32143214{
32153215 int offset = ip - td -> il_code ;
32163216 InterpBasicBlock * bb = td -> offset_to_bb [offset ];
@@ -3223,7 +3223,9 @@ get_bb (TransformData *td, unsigned char *ip)
32233223 bb -> index = td -> bb_count ++ ;
32243224 td -> offset_to_bb [offset ] = bb ;
32253225
3226- td -> basic_blocks = g_list_append_mempool (td -> mempool , td -> basic_blocks , bb );
3226+ /* Add the blocks in reverse order */
3227+ if (make_list )
3228+ td -> basic_blocks = g_list_prepend_mempool (td -> mempool , td -> basic_blocks , bb );
32273229 }
32283230
32293231 return bb ;
@@ -3235,7 +3237,7 @@ get_bb (TransformData *td, unsigned char *ip)
32353237 * Compute the set of IL level basic blocks.
32363238 */
32373239static void
3238- get_basic_blocks (TransformData * td , MonoMethodHeader * header )
3240+ get_basic_blocks (TransformData * td , MonoMethodHeader * header , gboolean make_list )
32393241{
32403242 guint8 * start = (guint8 * )td -> il_code ;
32413243 guint8 * end = (guint8 * )td -> il_code + td -> code_size ;
@@ -3246,14 +3248,14 @@ get_basic_blocks (TransformData *td, MonoMethodHeader *header)
32463248 const MonoOpcode * opcode ;
32473249
32483250 td -> offset_to_bb = (InterpBasicBlock * * )mono_mempool_alloc0 (td -> mempool , sizeof (InterpBasicBlock * ) * (end - start + 1 ));
3249- get_bb (td , start );
3251+ get_bb (td , start , make_list );
32503252
32513253 for (i = 0 ; i < header -> num_clauses ; i ++ ) {
32523254 MonoExceptionClause * c = header -> clauses + i ;
3253- get_bb (td , start + c -> try_offset );
3254- get_bb (td , start + c -> handler_offset );
3255+ get_bb (td , start + c -> try_offset , make_list );
3256+ get_bb (td , start + c -> handler_offset , make_list );
32553257 if (c -> flags == MONO_EXCEPTION_CLAUSE_FILTER )
3256- get_bb (td , start + c -> data .filter_offset );
3258+ get_bb (td , start + c -> data .filter_offset , make_list );
32573259 }
32583260
32593261 while (ip < end ) {
@@ -3283,30 +3285,30 @@ get_basic_blocks (TransformData *td, MonoMethodHeader *header)
32833285 break ;
32843286 case MonoShortInlineBrTarget :
32853287 target = start + cli_addr + 2 + (signed char )ip [1 ];
3286- get_bb (td , target );
3288+ get_bb (td , target , make_list );
32873289 ip += 2 ;
3288- get_bb (td , ip );
3290+ get_bb (td , ip , make_list );
32893291 break ;
32903292 case MonoInlineBrTarget :
32913293 target = start + cli_addr + 5 + (gint32 )read32 (ip + 1 );
3292- get_bb (td , target );
3294+ get_bb (td , target , make_list );
32933295 ip += 5 ;
3294- get_bb (td , ip );
3296+ get_bb (td , ip , make_list );
32953297 break ;
32963298 case MonoInlineSwitch : {
32973299 guint32 n = read32 (ip + 1 );
32983300 guint32 j ;
32993301 ip += 5 ;
33003302 cli_addr += 5 + 4 * n ;
33013303 target = start + cli_addr ;
3302- get_bb (td , target );
3304+ get_bb (td , target , make_list );
33033305
33043306 for (j = 0 ; j < n ; ++ j ) {
33053307 target = start + cli_addr + (gint32 )read32 (ip );
3306- get_bb (td , target );
3308+ get_bb (td , target , make_list );
33073309 ip += 4 ;
33083310 }
3309- get_bb (td , ip );
3311+ get_bb (td , ip , make_list );
33103312 break ;
33113313 }
33123314 case MonoInlineR :
@@ -3318,8 +3320,12 @@ get_basic_blocks (TransformData *td, MonoMethodHeader *header)
33183320 }
33193321
33203322 if (i == CEE_THROW || i == CEE_ENDFINALLY || i == CEE_RETHROW )
3321- get_bb (td , ip );
3323+ get_bb (td , ip , make_list );
33223324 }
3325+
3326+ /* get_bb added blocks in reverse order, unreverse now */
3327+ if (make_list )
3328+ td -> basic_blocks = g_list_reverse (td -> basic_blocks );
33233329}
33243330
33253331static void
@@ -4084,7 +4090,7 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header,
40844090 exit_bb -> stack_height = -1 ;
40854091 }
40864092
4087- get_basic_blocks (td , header );
4093+ get_basic_blocks (td , header , td -> gen_sdb_seq_points );
40884094
40894095 if (!inlining )
40904096 initialize_clause_bblocks (td );
0 commit comments