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]

Fix PUT_MODE usages


If PUT_MODE is applied to a MEM, it can change the alignment and size
in the mem attributes since they may have defaulted based on the mode.
So if the attributes have already been set, one of the other functions
need to be called instead.  The major effect of this bug is efficiency
in that GCC will think things are less aligned then they are, but if the
item in question is a variable-sized field, attempts to take its address
will fail.  Most of the bad usages are in VIEW_CONVERT_EXPR, so this
can only happen for Ada.  It caused numerous test case failures on
Alpha and Sparc for Ada.

I looked at all occurrences of PUT_MODE in the compiler, and sent messages
yesterday about two that I didn't understand.  They both likely represent
bugs.  This was tested on alphaev56-dec-osf4.0c.

Sat Dec 29 15:48:54 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* expr.c (store_field): Use adjust_address, not PUT_MODE.
	(expand_expr, case VIEW_CONVERT_EXPR): Likewise.
	* reload1.c (eliminate_regs, case SUBREG): Likewise, but use
	adjust_address_nv.
	* varasm.c (make_decl_rtl): Likewise.
	* integrate.c (copy_rtx_and_substitute, case MEM): Likewise, but use
	replace_equiv_address_nv.

*** expr.c	2001/12/28 07:51:59	1.404
--- expr.c	2001/12/29 20:50:39
*************** store_field (target, bitsize, bitpos, mo
*** 5004,5010 ****
  	  (build_qualified_type (type, TYPE_QUALS (type) | TYPE_QUAL_CONST),
  	   0, 1, 1);
!       rtx blk_object = copy_rtx (object);
! 
!       PUT_MODE (blk_object, BLKmode);
  
        if (bitsize != (HOST_WIDE_INT) GET_MODE_BITSIZE (GET_MODE (target)))
--- 5007,5011 ----
  	  (build_qualified_type (type, TYPE_QUALS (type) | TYPE_QUAL_CONST),
  	   0, 1, 1);
!       rtx blk_object = adjust_address (object, BLKmode, 0);
  
        if (bitsize != (HOST_WIDE_INT) GET_MODE_BITSIZE (GET_MODE (target)))
*************** expand_expr (exp, target, tmode, modifie
*** 7338,7347 ****
  	      rtx new = assign_stack_temp_for_type (TYPE_MODE (type),
  						    temp_size, 0, type);
! 	      rtx new_with_op0_mode = copy_rtx (new);
  
  	      if (TREE_ADDRESSABLE (exp))
  		abort ();
  
- 	      PUT_MODE (new_with_op0_mode, GET_MODE (op0));
  	      if (GET_MODE (op0) == BLKmode)
  		emit_block_move (new_with_op0_mode, op0,
--- 7339,7347 ----
  	      rtx new = assign_stack_temp_for_type (TYPE_MODE (type),
  						    temp_size, 0, type);
! 	      rtx new_with_op0_mode = adjust_address (new, GET_MODE (op0), 0);
  
  	      if (TREE_ADDRESSABLE (exp))
  		abort ();
  
  	      if (GET_MODE (op0) == BLKmode)
  		emit_block_move (new_with_op0_mode, op0,
*************** expand_expr (exp, target, tmode, modifie
*** 7353,7357 ****
  	    }
        
! 	  PUT_MODE (op0, TYPE_MODE (type));
  	}
  
--- 7353,7357 ----
  	    }
        
! 	  op0 = adjust_address (op0, TYPE_MODE (type), 0);
  	}
  
*** integrate.c	2001/12/28 01:46:22	1.178
--- integrate.c	2001/12/29 20:50:43
*************** copy_rtx_and_substitute (orig, map, for_
*** 2264,2271 ****
  	}
  
!       copy = rtx_alloc (MEM);
!       PUT_MODE (copy, mode);
!       XEXP (copy, 0) = copy_rtx_and_substitute (XEXP (orig, 0), map, 0);
!       MEM_COPY_ATTRIBUTES (copy, orig);
  
        /* If inlining and this is not for the LHS, turn off RTX_UNCHANGING_P
--- 2264,2270 ----
  	}
  
!      copy = replace_equiv_address_nv (orig,
! 				      copy_rtx_and_substitute (XEXP (orig, 0),
! 							       map, 0));
  
        /* If inlining and this is not for the LHS, turn off RTX_UNCHANGING_P
*** reload1.c	2001/12/23 16:07:06	1.317
--- reload1.c	2001/12/29 20:50:51
*************** eliminate_regs (x, mem_mode, insn)
*** 2553,2564 ****
  		  || x_size == new_size)
  	      )
! 	    {
! 	      int offset = SUBREG_BYTE (x);
! 	      enum machine_mode mode = GET_MODE (x);
! 
! 	      PUT_MODE (new, mode);
! 	      XEXP (new, 0) = plus_constant (XEXP (new, 0), offset);
! 	      return new;
! 	    }
  	  else
  	    return gen_rtx_SUBREG (GET_MODE (x), new, SUBREG_BYTE (x));
--- 2553,2557 ----
  		  || x_size == new_size)
  	      )
! 	    return adjust_address_nv (x, GET_MODE (x), SUBREG_BYTE (x));
  	  else
  	    return gen_rtx_SUBREG (GET_MODE (x), new, SUBREG_BYTE (x));
*** varasm.c	2001/12/28 17:57:50	1.238
--- varasm.c	2001/12/29 20:50:56
*************** make_decl_rtl (decl, asmspec)
*** 841,848 ****
        /* If the old RTL had the wrong mode, fix the mode.  */
        if (GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
! 	{
! 	  rtx rtl = DECL_RTL (decl);
! 	  PUT_MODE (rtl, DECL_MODE (decl));
! 	}
  
        /* ??? Another way to do this would be to do what halfpic.c does
--- 841,846 ----
        /* If the old RTL had the wrong mode, fix the mode.  */
        if (GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
! 	SET_DECL_RTL (decl, adjust_address_nv (DECL_RTL (decl),
! 					       DECL_MODE (decl), 0));
  
        /* ??? Another way to do this would be to do what halfpic.c does


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