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]

Properly update RTL in put_var_into_stack


This came up in a proprietary Ada code.  If you have two DImode variables that
are arrays, you assign one to the other, use both in an array reference
and reference one in a nested function, we'll get an ICE in fixup_var_refs_1.
The reason is that we call put_var_into_stack twice.  The first time, we
allow ADDRESSOF and the second we don't. That second one makes new RTL
that's not in DECL_RTL.  So this patch updates the one in DECL_RTL too.

Tested on x86-64-linux.

2004-03-29  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* function.c (put_var_into_stack): If old RTL was ADDRESSOF, update
	the address inside the old RTL.

*** function.c	27 Mar 2004 16:18:56 -0000	1.506
--- function.c	29 Mar 2004 14:46:45 -0000
*************** void
*** 1288,1292 ****
  put_var_into_stack (tree decl, int rescan)
  {
!   rtx reg;
    enum machine_mode promoted_mode, decl_mode;
    struct function *function = 0;
--- 1288,1292 ----
  put_var_into_stack (tree decl, int rescan)
  {
!   rtx orig_reg, reg;
    enum machine_mode promoted_mode, decl_mode;
    struct function *function = 0;
*************** put_var_into_stack (tree decl, int resca
*** 1300,1306 ****
  
    /* Get the current rtl used for this object and its original mode.  */
!   reg = (TREE_CODE (decl) == SAVE_EXPR
! 	 ? SAVE_EXPR_RTL (decl)
! 	 : DECL_RTL_IF_SET (decl));
  
    /* No need to do anything if decl has no rtx yet
--- 1300,1306 ----
  
    /* Get the current rtl used for this object and its original mode.  */
!  orig_reg = reg = (TREE_CODE (decl) == SAVE_EXPR
! 		   ? SAVE_EXPR_RTL (decl)
! 		   : DECL_RTL_IF_SET (decl));
  
    /* No need to do anything if decl has no rtx yet
*************** put_var_into_stack (tree decl, int resca
*** 1367,1370 ****
--- 1367,1376 ----
  	put_reg_into_stack (function, reg, TREE_TYPE (decl), promoted_mode,
  			    decl_mode, volatilep, 0, usedp, 0);
+ 
+ 	  /* If this was previously a MEM but we've removed the ADDRESSOF,
+ 	     set this address into that MEM so we always use the same
+ 	     rtx for this variable.  */
+ 	  if (orig_reg != reg && GET_CODE (orig_reg) == MEM)
+ 	    XEXP (orig_reg, 0) = XEXP (reg, 0);
      }
    else if (GET_CODE (reg) == CONCAT)


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