This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Check all insns in fallthru to see if label is mentioned
- To: gcc-patches at gcc dot gnu dot org
- Subject: PATCH: Check all insns in fallthru to see if label is mentioned
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- Date: Mon, 1 Oct 2001 12:19:00 -0400 (EDT)
On the vax, a label in an addr_diff_vec can be inadvertantly deleted by
try_optimize_cfg. Currently, try_optimize_cfg just checks the insn at
the end of the previous block for a condjump which mentions the label.
This patch extends the check to look at all insns from the end of the
previous block up to but not including the label.
Bootstrap checked with no regressions on hppa1.1-hp-hpux10.20. On the
vax, it has been confirmed that it resolves the problem in question.
Unfortunately, there are still more bugs to stomp.
OK?
Dave
--
J. David Anglin dave.anglin@nrc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
2001-10-01 John David Anglin <dave@hiauly1.hia.nrc.ca>
* cfgcleanup.c (label_mentioned_p): New function.
(try_optimize_cfg): Use it.
--- cfgcleanup.c.orig Fri Sep 21 18:29:23 2001
+++ cfgcleanup.c Fri Sep 28 16:09:38 2001
@@ -52,6 +52,7 @@
rtx *, rtx *));
static bool delete_unreachable_blocks PARAMS ((void));
+static bool label_mentioned_p PARAMS ((rtx, rtx));
static bool tail_recursion_label_p PARAMS ((rtx));
static void merge_blocks_move_predecessor_nojumps PARAMS ((basic_block,
basic_block));
@@ -248,6 +249,22 @@
return changed;
}
+/* Return true if LABEL is mentioned in any insn from INSN up to
+ but not including the label. */
+
+static bool
+label_mentioned_p (label, insn)
+ rtx label, insn;
+{
+ rtx x;
+
+ for (x = insn; x != label; x = NEXT_INSN (x))
+ if (reg_mentioned_p (label, x))
+ return true;
+
+ return false;
+}
+
/* Return true if LABEL is used for tail recursion. */
static bool
@@ -1096,7 +1113,7 @@
/* If previous block ends with condjump jumping to next BB,
we can't delete the label. */
&& (b->pred->src == ENTRY_BLOCK_PTR
- || !reg_mentioned_p (b->head, b->pred->src->end)))
+ || !label_mentioned_p (b->head, b->pred->src->end)))
{
rtx label = b->head;
b->head = NEXT_INSN (b->head);