This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch for PR 28574 (tablejump label disappears)
- From: Steve Ellcey <sje at cup dot hp dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 19 Sep 2006 16:08:09 -0700 (PDT)
- Subject: Patch for PR 28574 (tablejump label disappears)
- Reply-to: sje at cup dot hp dot com
PR 28574 on IA64 occurs when we have a then-clause basic block with a
tablejump in it. If we can predicate the tablejump and move it up to
the if-block then we remove the then-block. But when the then-block
gets removed, the jump table, still in use by the predicated tablejump
gets removed too.
It might be possible to move the jumptable up from the then-block to the
if-block in this situation but I don't know how to do it so I just turn
off the predication conversion when the then-block contains a tablejump.
Tested on IA64 HP-UX and Linux with no regressions. I also attached a
test case which only really fails on IA64 (other targets with
predication might be affected) but since it doesn't contain any IA64
specifics I put it in gcc.dg instead of gcc.target.
OK to check in?
2006-09-19 Steve Ellcey <sje@cup.hp.com>
PR 28574
* ifcvt.c (dead_or_predicable): Don't predicate then blocks
with tablejumps in them.
Index: ifcvt.c
===================================================================
--- ifcvt.c (revision 117048)
+++ ifcvt.c (working copy)
@@ -3560,6 +3560,13 @@ dead_or_predicable (basic_block test_bb,
head = BB_HEAD (merge_bb);
end = BB_END (merge_bb);
+ /* If merge_bb ends with a tablejump, predicating/moving insn's
+ into test_bb and then deleting merge_bb will result in the jumptable
+ that follows merge_bb being removed along with merge_bb and then we
+ get an unresolved reference to the jumptable. */
+ if (tablejump_p (end, NULL, NULL))
+ return FALSE;
+
if (LABEL_P (head))
head = NEXT_INSN (head);
if (NOTE_P (head))
2006-09-19 Steve Ellcey <sje@cup.hp.com>
PR 28574
* gcc.dg/pr28574.c: New test.
Index: gcc.dg/pr28574.c
===================================================================
--- gcc.dg/pr28574.c (revision 0)
+++ gcc.dg/pr28574.c (revision 0)
@@ -0,0 +1,74 @@
+/* On IA64 This test resulted in a missing jumptable and an undefined
+ reference to a label. Make sure we can compile and link it with
+ no undefs at -O2. */
+
+/* { dg-do link } */
+/* { dg-options "-O2" } */
+
+typedef enum yasm_module_type {
+ YASM_MODULE_ARCH = 0,
+ YASM_MODULE_DBGFMT,
+ YASM_MODULE_OBJFMT,
+ YASM_MODULE_LISTFMT,
+ YASM_MODULE_OPTIMIZER
+} yasm_module_type;
+
+struct yasm_module {
+ const char *name;
+};
+
+typedef struct yasm_module yasm_arch_module;
+typedef struct yasm_module yasm_dbgfmt_module;
+typedef struct yasm_module yasm_objfmt_module;
+typedef struct yasm_module yasm_listfmt_module;
+typedef struct yasm_module yasm_optimizer_module;
+
+typedef struct module {
+ void *data;
+} module;
+
+static struct {
+ module *m;
+ int n;
+} module_types[] = {
+ {},
+};
+
+void
+yasm_list_modules(yasm_module_type type,
+ void (*printfunc) (const char *name))
+{
+ int i;
+ module *modules = module_types[type].m;
+ yasm_arch_module *arch;
+ yasm_dbgfmt_module *dbgfmt;
+ yasm_objfmt_module *objfmt;
+ yasm_listfmt_module *listfmt;
+ yasm_optimizer_module *optimizer;
+
+ for (i=0; i<2; i++) {
+ switch (type) {
+ case YASM_MODULE_ARCH:
+ arch = modules[i].data;
+ printfunc(arch->name);
+ break;
+ case YASM_MODULE_DBGFMT:
+ dbgfmt = modules[i].data;
+ printfunc(dbgfmt->name);
+ break;
+ case YASM_MODULE_OBJFMT:
+ objfmt = modules[i].data;
+ printfunc(objfmt->name);
+ break;
+ case YASM_MODULE_LISTFMT:
+ listfmt = modules[i].data;
+ printfunc(listfmt->name);
+ break;
+ case YASM_MODULE_OPTIMIZER:
+ optimizer = modules[i].data;
+ printfunc(optimizer->name);
+ }
+ }
+}
+
+main() {}