[PATCH] Fix -freorder-blocks-and-partition unwinding wrong-code (PR rtl-optimization/86108)

Jakub Jelinek jakub@redhat.com
Fri Jun 15 19:06:00 GMT 2018


Hi!

Testcase in the PR is too large to include in the testsuite.
The problem is that DF and RTL cross-jumping aren't really prepared to
handle properly EH landing pads which have in addition to EH incoming edges
some other edges (which is what my patch from a few months ago does in
case we have EH landing pads that need to be reachable from both hot and
cold partition).

The problem is that DF models the EH pads as having artificial sets of those
EH registers at the start of the block, so DF doesn't record those regs to
be live in the in set and in the out set of the EH landing pad that does a
crossing jump to it.  Then cross-jumping may come and merge an EH landing
pad with some other bb with the same content and we are doomed, because DF
doesn't say those EH registers are actually needed to be set.

The following patch fixes it by making sure we don't have EH landing pads
that are reachable also by the crossing edges by splitting the EH landing
pad bb we want to jump into and jumping (EDGE_CROSSING) only to the second
half, leaving the first part with no actual instructions to be the EH
landing pad.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2018-06-15  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/86108
	* bb-reorder.c (dw2_fix_up_crossing_landing_pad): Split old_bb
	after labels and jump from the new forwarder landing pad to the
	second part of old_bb rather than old_bb itself.

--- gcc/bb-reorder.c.jj	2018-05-31 21:51:18.508292965 +0200
+++ gcc/bb-reorder.c	2018-06-15 12:57:34.501095317 +0200
@@ -1507,8 +1507,11 @@ dw2_fix_up_crossing_landing_pad (eh_land
   new_lp->landing_pad = gen_label_rtx ();
   LABEL_PRESERVE_P (new_lp->landing_pad) = 1;
 
+  e = split_block_after_labels (old_bb);
+  old_bb = e->src;
+
   /* Create the forwarder block.  */
-  basic_block new_bb = create_forwarder_block (new_lp->landing_pad, old_bb);
+  basic_block new_bb = create_forwarder_block (new_lp->landing_pad, e->dest);
 
   /* Fix up the edges.  */
   for (ei = ei_start (old_bb->preds); (e = ei_safe_edge (ei)) != NULL; )

	Jakub



More information about the Gcc-patches mailing list