This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: RFA: Change D30V port to use init/mark/free machine_status


On Mon, Jan 08, 2001 at 07:52:56PM -0800, Nick Clifton wrote:
> Hi Guys,
> 
>   The patch changes the D30V port to use the init_machine_status,
>   mark_machine_status and free_machine_status functions instead of the
>   old save_machine_status and restore_machine_status functions.
> 
>   OK to apply ?

No, it causes a segfault in building _muldi:

Program received signal SIGSEGV, Segmentation fault.
0x8183086 in mark_used_regs (pbi=0x82be7c8, x=0x4010ad50, cond=0x0,
insn=0x401a7160) at /key/src/egcs-current/egcs/gcc/flow.c:5990
5990            if (fmt[i] == 'e')
(gdb) where
#0  0x8183086 in mark_used_regs (pbi=0x82be7c8, x=0x4010ad50, cond=0x0, insn=0x401a7160)
    at /key/src/egcs-current/egcs/gcc/flow.c:5990
#1  0x81830ab in mark_used_regs (pbi=0x82be7c8, x=0x401a9b00, cond=0x0, insn=0x401a7160)
    at /key/src/egcs-current/egcs/gcc/flow.c:5998
#2  0x8182fc4 in mark_used_regs (pbi=0x82be7c8, x=0x401a9b10, cond=0x0, insn=0x401a7160)
    at /key/src/egcs-current/egcs/gcc/flow.c:5918
#3  0x81830ee in mark_used_regs (pbi=0x82be7c8, x=0x401aa450, cond=0x0, insn=0x401a7160)
    at /key/src/egcs-current/egcs/gcc/flow.c:6004
#4  0x81802b2 in propagate_one_insn (pbi=0x82be7c8, insn=0x401a7160) at /key/src/egcs-current/egcs/gcc/flow.c:3847
#5  0x81c6837 in peephole2_optimize (dump_file=0x0) at /key/src/egcs-current/egcs/gcc/recog.c:3073
#6  0x80903c3 in rest_of_compilation (decl=0x4019b478) at /key/src/egcs-current/egcs/gcc/toplev.c:3536
#7  0x805fa3f in c_expand_body (fndecl=0x4019b478, nested_p=0) at /key/src/egcs-current/egcs/gcc/c-decl.c:6699
#8  0x805f82c in finish_function (nested=0) at /key/src/egcs-current/egcs/gcc/c-decl.c:6620
#9  0x804a030 in yyparse_1 () at c-parse.y:323
#10 0x804e9fe in yyparse () at /key/src/egcs-current/egcs/gcc/c-lex.c:154
#11 0x808e98a in compile_file (name=0xbfffe3c9 "libgcc2.i") at /key/src/egcs-current/egcs/gcc/toplev.c:2373
#12 0x809292b in main (argc=4, argv=0xbfffe114) at /key/src/egcs-current/egcs/gcc/toplev.c:4869
(gdb) print fmt
$3 = 0x4 <Address 0x4 out of bounds>
(gdb) print insn
$4 = 0x401a7160
(gdb) pr
(insn 132 130 133 (parallel[ 
            (set (reg/f:SI 63 sp)
                (plus:SI (reg/f:SI 63 sp)
                    
Program received signal SIGSEGV, Segmentation fault.
0x40063431 in _IO_vfprintf (s=0xbfffaec0, format=0x822848e "(%s",
ap=0xbfffd63c) at vfprintf.c:1259
1259    vfprintf.c: No such file or directory.
The program being debugged stopped while in a function called from GDB.
When the function (debug_rtx) is done executing, GDB will silently
stop (instead of continuing to evaluate the expression containing
the function call).
(gdb) 


> Cheers
> 	Nick
> 
> 2001-01-08  Nick Clifton  <nickc@redhat.com>
> 
> 	* config/d30v/d30v.c (d30v_eh_epilogue_sp_ofs): Delete.
> 	(d30v_return_addr_rtx): Delete.
> 	(d30v_expand_epilogue): Use eh_epilogue_sp_ofs field in the
> 	cfun->machine structure.
> 	(struct machine_function): Move to d30v.h
> 	(d30v_save_machine_status): Delete.
> 	(d30v_restore_machine_status): Delete.
> 	(d30v_init_machine_status): New Function.
> 	(d30v_mark_machine_status): New Function.
> 	(d30v_free_machine_status): New Function.
> 	(d30v_init_expanders): Use new functions.
> 	(d30v_return_addr): Use ra_rtx field in cfun->machine.
> 	(d30v_add_gc_roots): Remove d30v_eh_epilogue_sp_ofs and
> 	d30v_return_addr_rtx.
> 
> 	* config/d30v/d30v.h (struct_machine): Move here.
> 	Add eh_epilogue_sp_ofs field.
> 
> 	*config/d30v/d30v.md (epilogue): Initialise eh_epilogue_sp_ofs
> 	field in cfun->machine structure.
> 
> Index: config/d30v/d30v.c
> ===================================================================
> RCS file: /cvs/gcc/egcs/gcc/config/d30v/d30v.c,v
> retrieving revision 1.3
> diff -p -r1.3 d30v.c
> *** d30v.c	2000/05/27 19:53:21	1.3
> --- d30v.c	2001/01/09 03:41:10
> *************** static void d30v_add_gc_roots PARAMS ((v
> *** 52,67 ****
>   struct rtx_def *d30v_compare_op0;
>   struct rtx_def *d30v_compare_op1;
>   
> - /* Define the information needed to modify the epilogue for EH.  */
> - 
> - rtx d30v_eh_epilogue_sp_ofs;
> - 
>   /* Cached value of d30v_stack_info */
>   static d30v_stack_t *d30v_stack_cache = (d30v_stack_t *)0;
>   
> - /* Cache for __builtin_return_addr */
> - static rtx d30v_return_addr_rtx;
> - 
>   /* Values of the -mbranch-cost=n string.  */
>   int d30v_branch_cost = D30V_DEFAULT_BRANCH_COST;
>   const char *d30v_branch_cost_string = (const char *)0;
> --- 52,60 ----
> *************** d30v_expand_epilogue ()
> *** 2594,2600 ****
>     for (i = GPR_FIRST; i <= GPR_LAST; i++)
>       if (info->save_p[i] == 1)
>         {
> ! 	if (d30v_eh_epilogue_sp_ofs && i == GPR_LINK)
>   	  extra_stack = 4;
>   	else
>   	  {
> --- 2587,2593 ----
>     for (i = GPR_FIRST; i <= GPR_LAST; i++)
>       if (info->save_p[i] == 1)
>         {
> ! 	if (cfun->machine->eh_epilogue_sp_ofs && i == GPR_LINK)
>   	  extra_stack = 4;
>   	else
>   	  {
> *************** d30v_expand_epilogue ()
> *** 2615,2629 ****
>   
>     if (extra_stack)
>       {
> !       if (d30v_eh_epilogue_sp_ofs)
> ! 	emit_insn (gen_addsi3 (d30v_eh_epilogue_sp_ofs,
> ! 			       d30v_eh_epilogue_sp_ofs,
>   			       GEN_INT (extra_stack)));
>         else
>           emit_insn (gen_addsi3 (sp, sp, GEN_INT (extra_stack)));
>       }
> !   if (d30v_eh_epilogue_sp_ofs)
> !     emit_insn (gen_addsi3 (sp, sp, d30v_eh_epilogue_sp_ofs));
>   
>     /* Now emit the return instruction.  */
>     emit_jump_insn (gen_rtx_RETURN (VOIDmode));
> --- 2608,2622 ----
>   
>     if (extra_stack)
>       {
> !       if (cfun->machine->eh_epilogue_sp_ofs)
> ! 	emit_insn (gen_addsi3 (cfun->machine->eh_epilogue_sp_ofs,
> ! 			       cfun->machine->eh_epilogue_sp_ofs,
>   			       GEN_INT (extra_stack)));
>         else
>           emit_insn (gen_addsi3 (sp, sp, GEN_INT (extra_stack)));
>       }
> !   if (cfun->machine->eh_epilogue_sp_ofs)
> !     emit_insn (gen_addsi3 (sp, sp, cfun->machine->eh_epilogue_sp_ofs));
>   
>     /* Now emit the return instruction.  */
>     emit_jump_insn (gen_rtx_RETURN (VOIDmode));
> *************** d30v_adjust_cost (insn, link, dep_insn, 
> *** 3595,3628 ****
>   }
>   
>   
> ! /* Functions to save and restore d30v_return_addr_rtx.  */
> ! 
> ! struct machine_function
> ! {
> !   rtx ra_rtx;
> ! };
>   
>   static void
> ! d30v_save_machine_status (p)
>        struct function *p;
>   {
> !   struct machine_function *machine =
>       (struct machine_function *) xmalloc (sizeof (struct machine_function));
>   
> !   p->machine = machine;
> !   machine->ra_rtx = d30v_return_addr_rtx;
>   }
>   
>   static void
> ! d30v_restore_machine_status (p)
>        struct function *p;
>   {
>     struct machine_function *machine = p->machine;
>   
> !   d30v_return_addr_rtx = machine->ra_rtx;
>   
>     free (machine);
> !   p->machine = (struct machine_function *)0;
>   }
>   
>   /* Do anything needed before RTL is emitted for each function.  */
> --- 3588,3626 ----
>   }
>   
>   
> ! /* Routine to allocate, mark and free a per-function,
> !    machine specific structure.  */
>   
>   static void
> ! d30v_init_machine_status (p)
>        struct function *p;
>   {
> !   p->machine =
>       (struct machine_function *) xmalloc (sizeof (struct machine_function));
> + }
>   
> ! static void
> ! d30v_mark_machine_status (p)
> !      struct function * p;
> ! {
> !   if (p->machine == NULL)
> !     return;
> !   
> !   ggc_mark_rtx (p->machine->ra_rtx);
> !   ggc_mark_rtx (p->machine->eh_epilogue_sp_ofs);
>   }
>   
>   static void
> ! d30v_free_machine_status (p)
>        struct function *p;
>   {
>     struct machine_function *machine = p->machine;
>   
> !   if (machine == NULL)
> !     return;
>   
>     free (machine);
> !   p->machine = NULL;
>   }
>   
>   /* Do anything needed before RTL is emitted for each function.  */
> *************** d30v_restore_machine_status (p)
> *** 3630,3641 ****
>   void
>   d30v_init_expanders ()
>   {
> -   d30v_return_addr_rtx = NULL_RTX;
> -   d30v_eh_epilogue_sp_ofs = NULL_RTX;
> - 
>     /* Arrange to save and restore machine status around nested functions.  */
> !   save_machine_status = d30v_save_machine_status;
> !   restore_machine_status = d30v_restore_machine_status;
>   }
>   
>   /* Find the current function's return address.
> --- 3628,3637 ----
>   void
>   d30v_init_expanders ()
>   {
>     /* Arrange to save and restore machine status around nested functions.  */
> !   init_machine_status = d30v_init_machine_status;
> !   mark_machine_status = d30v_mark_machine_status;
> !   free_machine_status = d30v_free_machine_status;
>   }
>   
>   /* Find the current function's return address.
> *************** d30v_return_addr ()
> *** 3650,3660 ****
>   {
>     rtx ret;
>   
> !   if ((ret = d30v_return_addr_rtx) == NULL)
>       {
>         rtx init;
>   
> !       d30v_return_addr_rtx = ret = gen_reg_rtx (Pmode);
>   
>         init = gen_rtx (SET, VOIDmode, ret, gen_rtx (REG, Pmode, GPR_LINK));
>         push_topmost_sequence ();
> --- 3646,3658 ----
>   {
>     rtx ret;
>   
> !   ret = cfun->machine->ra_rtx;
> !   
> !   if (ret == NULL)
>       {
>         rtx init;
>   
> !       cfun->machine->ra_rtx = ret = gen_reg_rtx (Pmode);
>   
>         init = gen_rtx (SET, VOIDmode, ret, gen_rtx (REG, Pmode, GPR_LINK));
>         push_topmost_sequence ();
> *************** d30v_add_gc_roots ()
> *** 3673,3678 ****
>   {
>     ggc_add_rtx_root (&d30v_compare_op0, 1);
>     ggc_add_rtx_root (&d30v_compare_op1, 1);
> -   ggc_add_rtx_root (&d30v_eh_epilogue_sp_ofs, 1);
> -   ggc_add_rtx_root (&d30v_return_addr_rtx, 1);
>   }
> --- 3671,3674 ----
> 
> Index: config/d30v/d30v.h
> ===================================================================
> RCS file: /cvs/gcc/egcs/gcc/config/d30v/d30v.h,v
> retrieving revision 1.15
> diff -p -r1.15 d30v.h
> *** d30v.h	2001/01/01 20:35:28	1.15
> --- d30v.h	2001/01/09 03:41:11
> *************** typedef int CUMULATIVE_ARGS;
> *** 2870,2875 ****
> --- 2870,2885 ----
>      varargs.  */
>   /* #define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) */
>   
> + /* A C structure for machine-specific, per-function data.
> +    This is added to the cfun structure.  */
> + typedef struct machine_function
> + {
> +   /* Additionsl stack adjustment in __builtin_eh_throw.  */
> +   struct rtx_def * eh_epilogue_sp_ofs;
> +   /* Records __builtin_return address.  */
> +   struct rtx_def * ra_rtx;
> + } machine_function;
> + 
>   
>   /* Generating Code for Profiling.  */
>   
> Index: config/d30v/d30v.md
> ===================================================================
> RCS file: /cvs/gcc/egcs/gcc/config/d30v/d30v.md,v
> retrieving revision 1.4
> diff -p -r1.4 d30v.md
> *** d30v.md	2000/11/27 06:18:24	1.4
> --- d30v.md	2001/01/09 03:41:11
> ***************
> *** 2971,2977 ****
>     ""
>     "
>   {
> !   d30v_eh_epilogue_sp_ofs = operands[1];
>     if (GET_CODE (operands[2]) != REG || REGNO (operands[2]) != GPR_LINK)
>       {
>         rtx ra = gen_rtx_REG (Pmode, GPR_LINK);
> --- 2971,2977 ----
>     ""
>     "
>   {
> !   cfun->machine->eh_epilogue_sp_ofs = operands[1];
>     if (GET_CODE (operands[2]) != REG || REGNO (operands[2]) != GPR_LINK)
>       {
>         rtx ra = gen_rtx_REG (Pmode, GPR_LINK);

-- 
Michael Meissner, Red Hat, Inc.  (GCC group)
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]