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]
Other format: [Raw text]

Re: [PATCH?, 4.7 regression] Crash in ira-costs.c with -fschedule-insns -fsched-pressure -fdump-rtl-sched1


On 02/14/2012 12:00 PM, Ulrich Weigand wrote:
Hello,

compiling anything, even just an empty function, with
   -fschedule-insns -fsched-pressure -fdump-rtl-sched1
causes the compiler to crash:

Program received signal SIGSEGV, Segmentation fault.
0x0840d9e0 in REG_N_REFS (regno=58) at ../../gcc-head/gcc/regs.h:75
75        return regstat_n_sets_and_refs[regno].refs;
(gdb) bt
#0  0x0840d9e0 in REG_N_REFS (regno=58) at ../../gcc-head/gcc/regs.h:75
#1  0x08411120 in print_pseudo_costs (f=0x8e3fad0) at ../../gcc-head/gcc/ira-costs.c:1433
#2  0x08412046 in find_costs_and_classes (dump_file=0x8e3fad0) at ../../gcc-head/gcc/ira-costs.c:1806
#3  0x084129f2 in ira_set_pseudo_classes (dump_file=0x8e3fad0) at ../../gcc-head/gcc/ira-costs.c:2067
#4  0x089a9f08 in sched_init () at ../../gcc-head/gcc/haifa-sched.c:4838

This is because sched_init calls ira_set_pseudo_classes without having
called regstat_init_n_sets_and_refs first, but the latter is a prerequisite
for using REG_N_REFS.  All other callers of ira_set_pseudo_classes seem to
initialize the regstat array first.

This is fixed by the following patch.  However, I'm not quite sure if this is
the best way to fix the problem, given that the REG_N_REFS use occurs only for
debug output purposes -- should we actually do the work to compute the regstat
array just for that, or can print_pseudo_costs be changed instead?


Sorry, Ulrich. I am afraid that you missed my message about solving this PR two week ago.

http://gcc.gnu.org/ml/gcc-patches/2012-02/msg00101.html

ChangeLog:

	* haifa-sched.c (sched_init): Call regstat_init_n_sets_and_refs and
	regstat_free_n_sets_and_refs before/after ira_set_pseudo_classes call.


=== modified file 'gcc/haifa-sched.c' --- gcc/haifa-sched.c 2012-02-11 01:34:30 +0000 +++ gcc/haifa-sched.c 2012-02-14 16:41:47 +0000 @@ -6281,7 +6281,9 @@ { int i, max_regno = max_reg_num ();

+      regstat_init_n_sets_and_refs ();
        ira_set_pseudo_classes (sched_verbose ? sched_dump : NULL);
+      regstat_free_n_sets_and_refs ();
        sched_regno_pressure_class
  	= (enum reg_class *) xmalloc (max_regno * sizeof (enum reg_class));
        for (i = 0; i<  max_regno; i++)




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