+/* Recompute BLOCK_TO_BB and BB_FOR_BLOCK for current region so that blocks
+ are sorted in topological order (it might have been invalidated by
+ redirecting an edge). */
+static void
+sel_recompute_toporder (void)
+{
+ int i, n, rgn;
+ int *postorder, n_blocks;
+
+ postorder = XALLOCAVEC (int, n_basic_blocks);
+ n_blocks = post_order_compute (postorder, false, false);
+
+ rgn = CONTAINING_RGN (BB_TO_BLOCK (0));
+ for (n = 0, i = n_blocks - 1; i >= 0; i--)
+ if (CONTAINING_RGN (postorder[i]) == rgn)
+ {
+ BLOCK_TO_BB (postorder[i]) = n;
+ BB_TO_BLOCK (n) = postorder[i];
+ n++;
+ }
+
+ /* Assert that we updated info for all blocks. We may miss some blocks if
+ this function is called when redirecting an edge made a block
+ unreachable, but that block is not deleted yet. */
+ gcc_assert (n == RGN_NR_BLOCKS (rgn));
+}
+