Fix sparc segfault (Was: Re: [patch] Fix PR/14058)

Josef Zlomek zlomj9am@artax.karlin.mff.cuni.cz
Sat Feb 14 09:33:00 GMT 2004


> +FAIL: gcc.c-torture/unsorted/pp.c,  -O0  
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x0010be20 in set_decl_incoming_rtl (t=0xff1d1500, x=0xff1d40c0) at /vol/gnu/src/gcc/gcc-dist/gcc/emit-rtl.c:859
> 859               if (REG_P (XEXP (y, 0)))

The attached patch fixes the segfault.

y is

(expr_list (nil)
    (const_int 0 [0x0]))

and is a part of

(parallel:DF [
        (expr_list (nil)
            (const_int 0 [0x0]))
        (expr_list (reg:DF 44 %f12 [ f ])
            (const_int 0 [0x0]))
    ])

which was created in config/sparc/sparc.c:function_arg:5569:

5547              if ((regno - SPARC_FP_ARG_FIRST) < SPARC_INT_ARG_MAX * 2)
5548                {
5549                  int intreg;
5550
5551                  /* On incoming, we don't need to know that the value
5552                     is passed in %f0 and %i0, and it confuses other parts
5553                     causing needless spillage even on the simplest cases.  */
5554                  if (incoming_p)
5555                    return reg;
5556
5557                  intreg = (SPARC_OUTGOING_INT_ARG_FIRST
5558                            + (regno - SPARC_FP_ARG_FIRST) / 2);
5559
5560                  v0 = gen_rtx_EXPR_LIST (VOIDmode, reg, const0_rtx);
5561                  v1 = gen_rtx_EXPR_LIST (VOIDmode, gen_rtx_REG (mode, intreg),
5562                                          const0_rtx);
5563                  return gen_rtx_PARALLEL (mode, gen_rtvec (2, v0, v1));
5564                }
5565              else
5566                {
5567                  v0 = gen_rtx_EXPR_LIST (VOIDmode, NULL_RTX, const0_rtx);
5568                  v1 = gen_rtx_EXPR_LIST (VOIDmode, reg, const0_rtx);
5569                  return gen_rtx_PARALLEL (mode, gen_rtvec (2, v0, v1));
5570                }

Maybe we should add

if (incoming_p)
  return reg;

to the second branch too instead of my patch. I do not know what exactly means the
(parallel:DF [
        (expr_list (nil)
            (const_int 0 [0x0]))
        (expr_list (reg:DF 44 %f12 [ f ])
            (const_int 0 [0x0]))
    ])
here (why there should be that (nil)).

Josef

2004-02-14  Josef Zlomek  <zlomekj@suse.cz>

	* emit-rtl.c (set_decl_incoming_rtl): Fix segfault.

Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.379
diff -c -p -c -3 -p -r1.379 emit-rtl.c
*** emit-rtl.c	12 Feb 2004 18:25:09 -0000	1.379
--- emit-rtl.c	14 Feb 2004 07:28:23 -0000
*************** set_decl_incoming_rtl (tree t, rtx x)
*** 856,862 ****
        for (i = 0; i < XVECLEN (x, 0); i++)
  	{
  	  rtx y = XVECEXP (x, 0, i);
! 	  if (REG_P (XEXP (y, 0)))
  	    REG_ATTRS (XEXP (y, 0)) = get_reg_attrs (t, INTVAL (XEXP (y, 1)));
  	}
      }
--- 856,862 ----
        for (i = 0; i < XVECLEN (x, 0); i++)
  	{
  	  rtx y = XVECEXP (x, 0, i);
! 	  if (XEXP (y, 0) && REG_P (XEXP (y, 0)))
  	    REG_ATTRS (XEXP (y, 0)) = get_reg_attrs (t, INTVAL (XEXP (y, 1)));
  	}
      }



More information about the Gcc-patches mailing list