sysv/ms_abi attribute fix, part 3, ICE in IRA

Jan Hubicka hubicka@ucw.cz
Sun Dec 14 11:40:00 GMT 2008


Hi,
ira-cost is not doing lazy initialization of move_cost.  This is probably
OK in most cases because someone else initializes it anyway, but with ABI changes
we throw it away often and get NULL pointer dereferences.

Bootstrapped/regtested i686-linux, OK?

	Jan Hubicka  <jh@suse.cz>
	Kai Tietz <kai.tietz@onevision.com>
	* ira-cost.c (copy_cost): Lazilly initialize move_cost if needed.
Index: ira-costs.c
===================================================================
*** ira-costs.c	(revision 142597)
--- ira-costs.c	(working copy)
*************** copy_cost (rtx x, enum machine_mode mode
*** 139,146 ****
      ira_init_register_move_cost (mode);
  
    if (secondary_class != NO_REGS)
!     return (move_cost[mode][secondary_class][rclass] + sri.extra_cost
! 	    + copy_cost (x, mode, secondary_class, to_p, &sri));
  
    /* For memory, use the memory move cost, for (hard) registers, use
       the cost to move between the register classes, and use 2 for
--- 139,150 ----
      ira_init_register_move_cost (mode);
  
    if (secondary_class != NO_REGS)
!     {
!       if (!move_cost[mode])
!         init_move_cost (mode);
!       return (move_cost[mode][secondary_class][rclass] + sri.extra_cost
! 	      + copy_cost (x, mode, secondary_class, to_p, &sri));
!     }
  
    /* For memory, use the memory move cost, for (hard) registers, use
       the cost to move between the register classes, and use 2 for
*************** copy_cost (rtx x, enum machine_mode mode
*** 148,155 ****
    if (MEM_P (x) || rclass == NO_REGS)
      return sri.extra_cost + ira_memory_move_cost[mode][rclass][to_p != 0];
    else if (REG_P (x))
!     return
!       (sri.extra_cost + move_cost[mode][REGNO_REG_CLASS (REGNO (x))][rclass]);
    else
      /* If this is a constant, we may eventually want to call rtx_cost
         here.  */
--- 152,162 ----
    if (MEM_P (x) || rclass == NO_REGS)
      return sri.extra_cost + ira_memory_move_cost[mode][rclass][to_p != 0];
    else if (REG_P (x))
!     {
!       if (!move_cost[mode])
!         init_move_cost (mode);
!       return (sri.extra_cost + move_cost[mode][REGNO_REG_CLASS (REGNO (x))][rclass]);
!     }
    else
      /* If this is a constant, we may eventually want to call rtx_cost
         here.  */



More information about the Gcc-patches mailing list