http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49800

           Summary: segfault with -fsched-pressure -fdump-rtl-sched1
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: kreb...@gcc.gnu.org


t.c:

void foo (int a)
{
}


/home/andreas/clean/gcc-head-build/gcc/cc1 -O2 -fdump-rtl-sched1
-fsched-pressure -quiet t.c

Program received signal SIGSEGV, Segmentation fault.
print_pseudo_costs (f=0x80cc9340) at
/home/andreas/clean/gcc-head/gcc/ira-costs.c:1404
1404          if (REG_N_REFS (regno) <= 0)


#0  print_pseudo_costs (f=0x80cc9340) at
/home/andreas/clean/gcc-head/gcc/ira-costs.c:1404
#1  find_costs_and_classes (dump_file=0x80cc9340) at
/home/andreas/clean/gcc-head/gcc/ira-costs.c:1770
#2  0x00000000803edf9e in ira_set_pseudo_classes (dump_file=0x80cc9340)
    at /home/andreas/clean/gcc-head/gcc/ira-costs.c:2031
#3  0x000000008085cda8 in sched_init () at
/home/andreas/clean/gcc-head/gcc/haifa-sched.c:4250
#4  0x00000000808654f4 in haifa_sched_init () at
/home/andreas/clean/gcc-head/gcc/haifa-sched.c:4273
#5  0x00000000804dcbca in schedule_insns () at
/home/andreas/clean/gcc-head/gcc/sched-rgn.c:3299
#6  schedule_insns () at /home/andreas/clean/gcc-head/gcc/sched-rgn.c:3287
#7  0x00000000804dd4ce in rest_of_handle_sched () at
/home/andreas/clean/gcc-head/gcc/sched-rgn.c:3501

(gdb) p regstat_n_sets_and_refs
$1 = (regstat_n_sets_and_refs_t *) 0x0

regstat_n_sets_and_refs is not initialized when sched-pressure perhaps invoking
regstat_init_n_sets_and_refs in sched_init is needed?

This worked with 4.6. The check in print_pseudo_costs was:
  for (regno = max_reg_num () - 1; regno >= FIRST_PSEUDO_REGISTER; regno--)
    {
      if (regno_reg_rtx[regno] == NULL_RTX)
    continue;

and has been changed to:

  for (regno = max_reg_num () - 1; regno >= FIRST_PSEUDO_REGISTER; regno--)
    {
      if (REG_N_REFS (regno) <= 0)
    continue;

Reply via email to