On Fri, Mar 11, 2016 at 09:39:58PM +0100, Andreas Schwab wrote:
> I'm getting this crash on ia64 for gcc.c-torture/compile/pr58164.c:
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x40000000012286e0 in indirect_jump_optimize () at ../../gcc/ira.c:3865
> 3865              rtx_insn *def_insn = DF_REF_INSN (DF_REG_DEF_CHAIN (regno));

Breakpoint 1, indirect_jump_optimize () at /src/gcc.git/gcc/ira.c:3863
(gdb) s
(gdb) p regno
$1 = 328
(gdb) p df->def_regs[328]
$2 = (df_reg_info *) 0x19772d0
(gdb) p *df->def_regs[328]
$3 = {reg_chain = 0x1981e60, n_refs = 1}
(gdb) p *df->def_regs[328]->reg_chain
$4 = {base = {cl = DF_REF_ARTIFICIAL, type = DF_REF_REG_DEF, flags = 0, regno = 
328, reg = 0x7ffff6c271c8, next_loc = 0x0, chain = 0x0, insn_info = 0x0, 
next_reg = 0x0, prev_reg = 0x0, id = -1, ref_order = 22}, regular_ref = {base = 
{cl = DF_REF_ARTIFICIAL, type = DF_REF_REG_DEF, flags = 0, regno = 328, reg = 
0x7ffff6c271c8, next_loc = 0x0, chain = 0x0, insn_info = 0x0, next_reg = 0x0, 
prev_reg = 0x0, id = -1, ref_order = 22}, loc = 0x7ffff6cf8068}, artificial_ref 
= {base = {cl = DF_REF_ARTIFICIAL, type = DF_REF_REG_DEF, flags = 0, regno = 
328, reg = 0x7ffff6c271c8, next_loc = 0x0, chain = 0x0, insn_info = 0x0, 
next_reg = 0x0, prev_reg = 0x0, id = -1, ref_order = 22}, bb = 0x7ffff6cf8068}}

Bootstrapping the following (diff -w).

        * ira.c (indirect_jump_optimize): Ignore artificial defs.

diff --git a/gcc/ira.c b/gcc/ira.c
index 5e7a2ed..c4d76fc 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -3862,7 +3862,10 @@ indirect_jump_optimize (void)
       int regno = REGNO (SET_SRC (x));
       if (DF_REG_DEF_COUNT (regno) == 1)
        {
-         rtx_insn *def_insn = DF_REF_INSN (DF_REG_DEF_CHAIN (regno));
+         df_ref def = DF_REG_DEF_CHAIN (regno);
+         if (!DF_REF_IS_ARTIFICIAL (def))
+           {
+             rtx_insn *def_insn = DF_REF_INSN (def);
              rtx note = find_reg_note (def_insn, REG_LABEL_OPERAND, NULL_RTX);
 
              if (note)
@@ -3873,6 +3876,7 @@ indirect_jump_optimize (void)
                }
            }
        }
+    }
 
   if (rebuild_p)
     {

-- 
Alan Modra
Australia Development Lab, IBM

Reply via email to