This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH for crash in regclass
- To: Richard Henderson <rth at cygnus dot com>
- Subject: PATCH for crash in regclass
- From: Mark Mitchell <mark at markmitchell dot com>
- Date: Wed, 23 Sep 1998 22:40:49 -0700
- Cc: egcs-patches at cygnus dot com
- Reply-to: mark at markmitchell dot com
This change:
Tue Sep 15 19:09:06 1998 Richard Henderson <rth@cygnus.com>
* rtl.h (global_rtl): Add cfa entry.
(virtual_cfa_rtx, VIRTUAL_CFA_REGNUM): New.
(LAST_VIRTUAL_REGISTER): Update.
* emit-rtl.c (global_rtl): Add cfa entry.
(init_emit): Initialize it.
causes a crash when compiling this small C++ program:
void f ()
{
struct Init {
Init () {
}
};
}
when compiled with -O2. The reason is that save_for_inline_copying
needed a similar change to that made in init_emit. This is a classic
example of what happens when you have unnecessary code
duplication. :-(
Richard, may I install this patch?
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com
Wed Sep 23 22:32:31 1998 Mark Mitchell <mark@markmitchell.com>
* rtl.h (init_virtual_regs): New function.
* emit-rtl.c (init_virtual_regs): Define.
(insn_emit): Use it.
* integrace.c (save_for_inline_copying): Likewise.
Index: testsuite/g++.old-deja/g++.other/local2.C
===================================================================
RCS file: local2.C
diff -N local2.C
*** /dev/null Mon Dec 31 20:00:00 1979
--- local2.C Wed Sep 23 22:29:00 1998
***************
*** 0 ****
--- 1,10 ----
+ // Build don't link:
+ // Special g++ Options: -O2
+
+ void f ()
+ {
+ struct Init {
+ Init () {
+ }
+ };
+ }
Index: rtl.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/rtl.h,v
retrieving revision 1.52
diff -c -p -r1.52 rtl.h
*** rtl.h 1998/09/18 20:54:57 1.52
--- rtl.h 1998/09/24 05:29:07
*************** extern void add_insn_after PROTO ((rtx
*** 1310,1315 ****
--- 1310,1316 ----
extern void reorder_insns_with_line_notes PROTO ((rtx, rtx, rtx));
extern void emit_insn_after_with_line_notes PROTO ((rtx, rtx, rtx));
extern enum rtx_code classify_insn PROTO ((rtx));
+ extern void init_virtual_regs PROTO ((void));
extern rtx emit PROTO ((rtx));
/* Query and clear/ restore no_line_numbers. This is used by the
switch / case handling in stmt.c to give proper line numbers in
Index: emit-rtl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/emit-rtl.c,v
retrieving revision 1.35
diff -c -p -r1.35 emit-rtl.c
*** emit-rtl.c 1998/09/15 19:18:48 1.35
--- emit-rtl.c 1998/09/24 05:29:25
*************** gen_sequence ()
*** 3297,3302 ****
--- 3297,3314 ----
return result;
}
+ /* Put the various virtual registers into REGNO_REG_RTX. */
+
+ void
+ init_virtual_regs ()
+ {
+ regno_reg_rtx[VIRTUAL_INCOMING_ARGS_REGNUM] = virtual_incoming_args_rtx;
+ regno_reg_rtx[VIRTUAL_STACK_VARS_REGNUM] = virtual_stack_vars_rtx;
+ regno_reg_rtx[VIRTUAL_STACK_DYNAMIC_REGNUM] = virtual_stack_dynamic_rtx;
+ regno_reg_rtx[VIRTUAL_OUTGOING_ARGS_REGNUM] = virtual_outgoing_args_rtx;
+ regno_reg_rtx[VIRTUAL_CFA_REGNUM] = virtual_cfa_rtx;
+ }
+
/* Initialize data structures and variables in this file
before generating rtl for each function. */
*************** init_emit ()
*** 3339,3349 ****
bzero ((char *) regno_reg_rtx, regno_pointer_flag_length * sizeof (rtx));
/* Put copies of all the virtual register rtx into regno_reg_rtx. */
! regno_reg_rtx[VIRTUAL_INCOMING_ARGS_REGNUM] = virtual_incoming_args_rtx;
! regno_reg_rtx[VIRTUAL_STACK_VARS_REGNUM] = virtual_stack_vars_rtx;
! regno_reg_rtx[VIRTUAL_STACK_DYNAMIC_REGNUM] = virtual_stack_dynamic_rtx;
! regno_reg_rtx[VIRTUAL_OUTGOING_ARGS_REGNUM] = virtual_outgoing_args_rtx;
! regno_reg_rtx[VIRTUAL_CFA_REGNUM] = virtual_cfa_rtx;
/* Indicate that the virtual registers and stack locations are
all pointers. */
--- 3351,3357 ----
bzero ((char *) regno_reg_rtx, regno_pointer_flag_length * sizeof (rtx));
/* Put copies of all the virtual register rtx into regno_reg_rtx. */
! init_virtual_regs ();
/* Indicate that the virtual registers and stack locations are
all pointers. */
Index: integrate.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/integrate.c,v
retrieving revision 1.36
diff -c -p -r1.36 integrate.c
*** integrate.c 1998/09/15 10:03:13 1.36
--- integrate.c 1998/09/24 05:29:30
*************** save_for_inline_copying (fndecl)
*** 561,570 ****
regno_reg_rtx = reg_map;
/* Put copies of all the virtual register rtx into the new regno_reg_rtx. */
! regno_reg_rtx[VIRTUAL_INCOMING_ARGS_REGNUM] = virtual_incoming_args_rtx;
! regno_reg_rtx[VIRTUAL_STACK_VARS_REGNUM] = virtual_stack_vars_rtx;
! regno_reg_rtx[VIRTUAL_STACK_DYNAMIC_REGNUM] = virtual_stack_dynamic_rtx;
! regno_reg_rtx[VIRTUAL_OUTGOING_ARGS_REGNUM] = virtual_outgoing_args_rtx;
/* Likewise each label rtx must have a unique rtx as its copy. */
--- 561,567 ----
regno_reg_rtx = reg_map;
/* Put copies of all the virtual register rtx into the new regno_reg_rtx. */
! init_virtual_regs ();
/* Likewise each label rtx must have a unique rtx as its copy. */