* [PATCH] Fix up -freorder-blocks-and-partition -fnon-call-exceptions (PR middle-end/45458)
@ 2010-09-01 19:32 Jakub Jelinek
2010-09-01 19:49 ` Richard Henderson
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2010-09-01 19:32 UTC (permalink / raw)
To: gcc-patches
Hi!
add_labels_and_missing_jumps doesn't expect to see bbs that don't end with
a call nor jump and have more than one edge, which is quite common with
-fnon-call-exceptions, where the bb ends with a possibly throwing insn
and has fallthru edge and EH edge.
Fixed by treating the throwing insns the same as calls.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2010-09-01 Jakub Jelinek <jakub@redhat.com>
PR middle-end/45458
* bb-reorder.c (add_labels_and_missing_jumps): Treat
bbs ending with throwing insns like blocks ending with a call.
(fix_up_fall_thru_edges): Likewise.
* g++.dg/tree-prof/partition2.C: New test.
--- gcc/bb-reorder.c.jj 2010-07-13 00:10:16.000000000 +0200
+++ gcc/bb-reorder.c 2010-09-01 17:57:00.608377599 +0200
@@ -1299,7 +1299,9 @@ add_labels_and_missing_jumps (edge *cros
if (src && (src != ENTRY_BLOCK_PTR))
{
- if (!JUMP_P (BB_END (src)) && !block_ends_with_call_p (src))
+ if (!JUMP_P (BB_END (src))
+ && !block_ends_with_call_p (src)
+ && !can_throw_internal (BB_END (src)))
/* bb just falls through. */
{
/* make sure there's only one successor */
@@ -1316,9 +1318,9 @@ add_labels_and_missing_jumps (edge *cros
src->il.rtl->footer = unlink_insn_chain (barrier, barrier);
/* Mark edge as non-fallthru. */
crossing_edges[i]->flags &= ~EDGE_FALLTHRU;
- } /* end: 'if (GET_CODE ... ' */
- } /* end: 'if (src && src->index...' */
- } /* end: 'if (dest && dest->index...' */
+ } /* end: 'if (!JUMP_P ... ' */
+ } /* end: 'if (src && src !=...' */
+ } /* end: 'if (dest && dest !=...' */
} /* end: 'if (crossing_edges[i]...' */
} /* end for loop */
}
@@ -1375,19 +1377,21 @@ fix_up_fall_thru_edges (void)
fall_thru = succ2;
cond_jump = succ1;
}
- else if (!fall_thru && succ1 && block_ends_with_call_p (cur_bb))
- {
- edge e;
- edge_iterator ei;
+ else if (succ1
+ && (block_ends_with_call_p (cur_bb)
+ || can_throw_internal (BB_END (cur_bb))))
+ {
+ edge e;
+ edge_iterator ei;
- /* Find EDGE_CAN_FALLTHRU edge. */
- FOR_EACH_EDGE (e, ei, cur_bb->succs)
- if (e->flags & EDGE_CAN_FALLTHRU)
- {
- fall_thru = e;
- break;
- }
- }
+ /* Find EDGE_CAN_FALLTHRU edge. */
+ FOR_EACH_EDGE (e, ei, cur_bb->succs)
+ if (e->flags & EDGE_CAN_FALLTHRU)
+ {
+ fall_thru = e;
+ break;
+ }
+ }
if (fall_thru && (fall_thru->dest != EXIT_BLOCK_PTR))
{
--- gcc/testsuite/g++.dg/tree-prof/partition2.C.jj 2010-09-01 18:56:55.223489198 +0200
+++ gcc/testsuite/g++.dg/tree-prof/partition2.C 2010-09-01 18:58:07.477752523 +0200
@@ -0,0 +1,15 @@
+// PR middle-end/45458
+// { dg-require-effective-target freorder }
+// { dg-options "-fnon-call-exceptions -freorder-blocks-and-partition" }
+
+int
+main ()
+{
+ try
+ {
+ throw 6;
+ }
+ catch (...)
+ {
+ }
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix up -freorder-blocks-and-partition -fnon-call-exceptions (PR middle-end/45458)
2010-09-01 19:32 [PATCH] Fix up -freorder-blocks-and-partition -fnon-call-exceptions (PR middle-end/45458) Jakub Jelinek
@ 2010-09-01 19:49 ` Richard Henderson
0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2010-09-01 19:49 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On 09/01/2010 12:27 PM, Jakub Jelinek wrote:
> PR middle-end/45458
> * bb-reorder.c (add_labels_and_missing_jumps): Treat
> bbs ending with throwing insns like blocks ending with a call.
> (fix_up_fall_thru_edges): Likewise.
>
> * g++.dg/tree-prof/partition2.C: New test.
Ok.
r~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-09-01 19:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-01 19:32 [PATCH] Fix up -freorder-blocks-and-partition -fnon-call-exceptions (PR middle-end/45458) Jakub Jelinek
2010-09-01 19:49 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).