This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] prevents labels referenced in the exception table to be deleted
- From: Christian BRUEL <christian dot bruel at st dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 10 Feb 2010 16:50:59 +0100
- Subject: [PATCH] prevents labels referenced in the exception table to be deleted
Hello,
While running validations on the SH for PR target/42841, we found an
issue with undefined labels, that happened to be landing pad entries
deleted by reorg_redirect_jump.
The situation was that we had sh_reorg inserting a constant pool just
bellow a barrier, which happens to be before a landing pad (whose first
instruction was a jump), and creates a jump over the constant pool. Then
reorg_redirect_jump (from dbr), deletes the label despite its reference
in the exception table.
A label referenced in the exception table is not dead and should not be
deleted when jumps are merged, This patch just prevents this.
Regards
Christian
2010-02-10 Christian Bruel <christian.bruel@st.com>
* except.c (eh_landing_pad_p): New function.
* except.h (eh_landing_pad_p): Declare.
* jump.c (redirect_jump_2): Check if label is a landing pad.
Index: jump.c
===================================================================
--- jump.c (revision 156449)
+++ jump.c (working copy)
@@ -1485,7 +1485,8 @@
if (olabel && --LABEL_NUSES (olabel) == 0 && delete_unused > 0
/* Undefined labels will remain outside the insn stream. */
- && INSN_UID (olabel))
+ && INSN_UID (olabel)
+ && !eh_landing_pad_p (olabel))
delete_related_insns (olabel);
if (invert)
invert_br_probabilities (jump);
Index: except.c
===================================================================
--- except.c (revision 156449)
+++ except.c (working copy)
@@ -455,6 +455,22 @@
return lp;
}
+bool
+eh_landing_pad_p (rtx lab)
+{
+ int n = VEC_length (eh_landing_pad, cfun->eh->lp_array);
+
+ int i;
+ for (i = 0; i < n; ++i)
+ {
+ eh_landing_pad lp = VEC_index (eh_landing_pad, cfun->eh->lp_array, i);
+ if (lp && lp->landing_pad == lab)
+ return true;
+ }
+
+ return false;
+}
+
eh_region
get_eh_region_from_number_fn (struct function *ifun, int i)
{
Index: except.h
===================================================================
--- except.h (revision 156449)
+++ except.h (working copy)
@@ -297,6 +297,8 @@
/* Return true if type A catches type B. */
extern int (*lang_eh_type_covers) (tree a, tree b);
+/* Return true if label l is a landing pad. */
+bool eh_landing_pad_p (rtx l);
/* Just because the user configured --with-sjlj-exceptions=no doesn't
mean that we can use call frame exceptions. Detect that the target