aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2003-03-25 20:20:34 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2003-03-25 19:20:34 +0000
commitcb9a1d9bb63b68d604dde99a916e48eb5171dd7e (patch)
tree0e69de262d22541befef3a9f7c91b5a102b2a66c /gcc
parentdcb0eee2a208c8283d8ae7dc59747664b33efcce (diff)
downloadgcc-cb9a1d9bb63b68d604dde99a916e48eb5171dd7e.zip
gcc-cb9a1d9bb63b68d604dde99a916e48eb5171dd7e.tar.gz
gcc-cb9a1d9bb63b68d604dde99a916e48eb5171dd7e.tar.bz2
re PR rtl-optimization/10056 ([HP-PA] ICE at -O2 when building c++ code from doxygen)
PR opt/10056 * cfglayout.c (fixup_reorder_chain): Fix dealing with the conditional jump jumping to the next instruction. * cfgrtl.c (force_nonfallthru_and_redirect): Likewise. From-SVN: r64854
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/cfglayout.c34
-rw-r--r--gcc/cfgrtl.c32
3 files changed, 70 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2e6bc1cf..ff7624a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+Mon Mar 24 20:03:03 CET 2003 Jan Hubicka <jh@suse.cz>
+
+ PR opt/10056
+ * cfglayout.c (fixup_reorder_chain): Fix dealing with the conditional
+ jump jumping to the next instruction.
+ * cfgrtl.c (force_nonfallthru_and_redirect): Likewise.
+
2003-03-25 Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
* doc/passes.texi (Passes): Properly document that we do not
diff --git a/gcc/cfglayout.c b/gcc/cfglayout.c
index 1f4f8fc..c95ac38 100644
--- a/gcc/cfglayout.c
+++ b/gcc/cfglayout.c
@@ -465,11 +465,43 @@ fixup_reorder_chain ()
&& e_fall->dest == EXIT_BLOCK_PTR))
continue;
+ /* The degenerated case of conditional jump jumping to the next
+ instruction can happen on target having jumps with side
+ effects.
+
+ Create temporarily the duplicated edge representing branch.
+ It will get unidentified by force_nonfallthru_and_redirect
+ that would otherwise get confused by fallthru edge not pointing
+ to the next basic block. */
+ if (!e_taken)
+ {
+ rtx note;
+ edge e_fake;
+
+ e_fake = unchecked_make_edge (bb, e_fall->dest, 0);
+
+ if (!redirect_jump (bb->end, block_label (bb), 0))
+ abort ();
+ note = find_reg_note (bb->end, REG_BR_PROB, NULL_RTX);
+ if (note)
+ {
+ int prob = INTVAL (XEXP (note, 0));
+
+ e_fake->probability = prob;
+ e_fake->count = e_fall->count * prob / REG_BR_PROB_BASE;
+ e_fall->probability -= e_fall->probability;
+ e_fall->count -= e_fake->count;
+ if (e_fall->probability < 0)
+ e_fall->probability = 0;
+ if (e_fall->count < 0)
+ e_fall->count = 0;
+ }
+ }
/* There is one special case: if *neither* block is next,
such as happens at the very end of a function, then we'll
need to add a new unconditional jump. Choose the taken
edge based on known or assumed probability. */
- if (RBI (bb)->next != e_taken->dest)
+ else if (RBI (bb)->next != e_taken->dest)
{
rtx note = find_reg_note (bb_end_insn, REG_BR_PROB, 0);
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 01b7e92..5e47236 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -78,7 +78,7 @@ static void commit_one_edge_insertion PARAMS ((edge, int));
static bool try_redirect_by_replacing_jump PARAMS ((edge, basic_block));
static rtx last_loop_beg_note PARAMS ((rtx));
static bool back_edge_of_syntactic_loop_p PARAMS ((basic_block, basic_block));
-static basic_block force_nonfallthru_and_redirect PARAMS ((edge, basic_block));
+basic_block force_nonfallthru_and_redirect PARAMS ((edge, basic_block));
/* Return true if NOTE is not one of the ones that must be kept paired,
so that we may simply delete it. */
@@ -930,7 +930,7 @@ redirect_edge_and_branch (e, target)
/* Like force_nonfallthru below, but additionally performs redirection
Used by redirect_edge_and_branch_force. */
-static basic_block
+basic_block
force_nonfallthru_and_redirect (e, target)
edge e;
basic_block target;
@@ -940,6 +940,34 @@ force_nonfallthru_and_redirect (e, target)
edge new_edge;
int abnormal_edge_flags = 0;
+ /* In the case the last instruction is conditional jump to the next
+ instruction, first redirect the jump itself and then continue
+ by creating an basic block afterwards to redirect fallthru edge. */
+ if (e->src != ENTRY_BLOCK_PTR && e->dest != EXIT_BLOCK_PTR
+ && any_condjump_p (e->src->end)
+ && JUMP_LABEL (e->src->end) == e->dest->head)
+ {
+ rtx note;
+ edge b = make_edge (e->src, target, 0);
+
+ if (!redirect_jump (e->src->end, block_label (target), 0))
+ abort ();
+ note = find_reg_note (e->src->end, REG_BR_PROB, NULL_RTX);
+ if (note)
+ {
+ int prob = INTVAL (XEXP (note, 0));
+
+ b->probability = prob;
+ b->count = e->count * prob / REG_BR_PROB_BASE;
+ e->probability -= e->probability;
+ e->count -= b->count;
+ if (e->probability < 0)
+ e->probability = 0;
+ if (e->count < 0)
+ e->count = 0;
+ }
+ }
+
if (e->flags & EDGE_ABNORMAL)
{
/* Irritating special case - fallthru edge to the same block as abnormal