Commit 6ee3c8e4 by Jakub Jelinek Committed by Jakub Jelinek

cfgrtl.c (try_redirect_by_replacing_jump): Allow redirect_jump to fail if target…

cfgrtl.c (try_redirect_by_replacing_jump): Allow redirect_jump to fail if target is EXIT_BLOCK_PTR, die otherwise.

	* cfgrtl.c (try_redirect_by_replacing_jump): Allow redirect_jump
	to fail if target is EXIT_BLOCK_PTR, die otherwise.
	(redirect_edge_and_branch): Likewise.
	* cfgcleanup.c (try_forward_edge): Don't force jump redirecting
	if target is EXIT_BLOCK_PTR.

	* gcc.c-torture/compile/20011229-2.c: New test.

From-SVN: r48399
parent 285f491a
2001-12-30 Jakub Jelinek <jakub@redhat.com>
* cfgrtl.c (try_redirect_by_replacing_jump): Allow redirect_jump
to fail if target is EXIT_BLOCK_PTR, die otherwise.
(redirect_edge_and_branch): Likewise.
* cfgcleanup.c (try_forward_edge): Don't force jump redirecting
if target is EXIT_BLOCK_PTR.
2001-12-29 David Edelsohn <edelsohn@gnu.org> 2001-12-29 David Edelsohn <edelsohn@gnu.org>
* gcc.c (init_gcc_spec): Do not link with static libgcc.a if * gcc.c (init_gcc_spec): Do not link with static libgcc.a if
......
...@@ -440,7 +440,8 @@ try_forward_edges (mode, b) ...@@ -440,7 +440,8 @@ try_forward_edges (mode, b)
int edge_probability = e->probability; int edge_probability = e->probability;
int edge_frequency; int edge_frequency;
if (threaded) /* Don't force if target is exit block. */
if (threaded && target != EXIT_BLOCK_PTR)
{ {
notice_new_block (redirect_edge_and_branch_force (e, target)); notice_new_block (redirect_edge_and_branch_force (e, target));
if (rtl_dump_file) if (rtl_dump_file)
......
...@@ -687,9 +687,18 @@ try_redirect_by_replacing_jump (e, target) ...@@ -687,9 +687,18 @@ try_redirect_by_replacing_jump (e, target)
if (rtl_dump_file) if (rtl_dump_file)
fprintf (rtl_dump_file, "Redirecting jump %i from %i to %i.\n", fprintf (rtl_dump_file, "Redirecting jump %i from %i to %i.\n",
INSN_UID (insn), e->dest->index, target->index); INSN_UID (insn), e->dest->index, target->index);
redirect_jump (insn, block_label (target), 0); if (!redirect_jump (insn, block_label (target), 0))
{
if (target == EXIT_BLOCK_PTR)
return false;
abort ();
}
} }
/* Cannot do anything for target exit block. */
else if (target == EXIT_BLOCK_PTR)
return false;
/* Or replace possibly complicated jump insn by simple jump insn. */ /* Or replace possibly complicated jump insn by simple jump insn. */
else else
{ {
...@@ -806,6 +815,8 @@ redirect_edge_and_branch (e, target) ...@@ -806,6 +815,8 @@ redirect_edge_and_branch (e, target)
int j; int j;
rtx new_label = block_label (target); rtx new_label = block_label (target);
if (target == EXIT_BLOCK_PTR)
return false;
if (GET_CODE (PATTERN (tmp)) == ADDR_VEC) if (GET_CODE (PATTERN (tmp)) == ADDR_VEC)
vec = XVEC (PATTERN (tmp), 0); vec = XVEC (PATTERN (tmp), 0);
else else
...@@ -843,11 +854,18 @@ redirect_edge_and_branch (e, target) ...@@ -843,11 +854,18 @@ redirect_edge_and_branch (e, target)
return false; return false;
/* If the insn doesn't go where we think, we're confused. */ /* If the insn doesn't go where we think, we're confused. */
if (JUMP_LABEL (insn) != old_label if (JUMP_LABEL (insn) != old_label)
/* If the substitution doesn't succeed, die. This can happen
if the back end emitted unrecognizable instructions. */
|| !redirect_jump (insn, block_label (target), 0))
abort (); abort ();
/* If the substitution doesn't succeed, die. This can happen
if the back end emitted unrecognizable instructions or if
target is exit block on some arches. */
if (!redirect_jump (insn, block_label (target), 0))
{
if (target == EXIT_BLOCK_PTR)
return false;
abort ();
}
} }
if (rtl_dump_file) if (rtl_dump_file)
......
2001-12-30 Jakub Jelinek <jakub@redhat.com>
* gcc.c-torture/compile/20011229-2.c: New test.
2001-12-29 Jakub Jelinek <jakub@redhat.com> 2001-12-29 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/debug-3.c: New test. * gcc.dg/debug-3.c: New test.
......
/* Test whether jump threading doesn't ICE if redirecting the jump to exit
block. */
extern int bar ();
extern void baz ();
void foo ()
{
int x;
do
{
if ((x = bar ()) == 1)
baz ();
}
while (x == 1);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment