diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-12-30 12:20:43 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-12-30 12:20:43 +0000 |
commit | 8963581acd743a88191f9c5438989979c6aa53d2 (patch) | |
tree | 1ecc1d8c6b8f60bc987e818fb2e0bd8e1daa2e46 | |
parent | 532b8ba03905e26e370b548e0bb6d90ad4518766 (diff) | |
download | gcc-8963581acd743a88191f9c5438989979c6aa53d2.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48399 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cfgcleanup.c | 3 | ||||
-rw-r--r-- | gcc/cfgrtl.c | 28 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/20011229-2.c | 17 |
5 files changed, 54 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 69b90569be0..76c405a5158 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +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> * gcc.c (init_gcc_spec): Do not link with static libgcc.a if diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index 9933defe433..98030325f29 100644 --- a/gcc/cfgcleanup.c +++ b/gcc/cfgcleanup.c @@ -440,7 +440,8 @@ try_forward_edges (mode, b) int edge_probability = e->probability; 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)); if (rtl_dump_file) diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c index 92d230eebce..e7e6e699acc 100644 --- a/gcc/cfgrtl.c +++ b/gcc/cfgrtl.c @@ -687,9 +687,18 @@ try_redirect_by_replacing_jump (e, target) if (rtl_dump_file) fprintf (rtl_dump_file, "Redirecting jump %i from %i to %i.\n", 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. */ else { @@ -806,6 +815,8 @@ redirect_edge_and_branch (e, target) int j; rtx new_label = block_label (target); + if (target == EXIT_BLOCK_PTR) + return false; if (GET_CODE (PATTERN (tmp)) == ADDR_VEC) vec = XVEC (PATTERN (tmp), 0); else @@ -843,11 +854,18 @@ redirect_edge_and_branch (e, target) return false; /* If the insn doesn't go where we think, we're confused. */ - 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)) + if (JUMP_LABEL (insn) != old_label) 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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 75d38d829b9..a756c74ae77 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +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> * gcc.dg/debug-3.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/compile/20011229-2.c b/gcc/testsuite/gcc.c-torture/compile/20011229-2.c new file mode 100644 index 00000000000..bb49bd18e34 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20011229-2.c @@ -0,0 +1,17 @@ +/* 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); +} |