In rest_of_reorder_blocks, we avoid reordering if !optimize_function_for_speed_p. However, we still call insert_section_bounary_note, which can cause problems because now, if we have a sequence of HOT-COLD-HOT blocks, the second set of HOT blocks will end up in the cold section. This causes assembler failures when using exception handling (subtracting labels from different sections).
Unfortunately, the only way I have of reproducing it is to apply a 67-patch quilt tree backporting the preliminary shrink-wrapping patches to gcc-4.6; then we get FAIL: g++.dg/tree-prof/partition2.C compilation, -Os -fprofile-use However, the problem is reasonably obvious. Bootstrapped and currently testing in the aforementioned 4.6 tree. Ok for trunk after testing there? Bernd
* bb-reorder.c (insert_section_boundary_note): Only do it if we reordered the blocks; i.e. not if !optimize_function_for_speed_p. Index: gcc/bb-reorder.c =================================================================== --- gcc/bb-reorder.c (revision 178030) +++ gcc/bb-reorder.c (working copy) @@ -1965,8 +1965,11 @@ insert_section_boundary_note (void) rtx new_note; int first_partition = 0; - if (flag_reorder_blocks_and_partition) - FOR_EACH_BB (bb) + if (!flag_reorder_blocks_and_partition + || !optimize_function_for_speed_p (cfun)) + return; + + FOR_EACH_BB (bb) { if (!first_partition) first_partition = BB_PARTITION (bb);