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]

[patch] expand_value_return


This patch corrects a problem that showed up on the stormy16 port.
In some circumstances, expand_value_return would generate a move
instruction with mismatched modes.  expand_value_return was passing
the wrong type to promote_mode when the return_reg represented a
promoted aggregate.  An example test case that demonstrated the
failure:

typedef struct
{
  char x;
} s1;

s1
f ()
{
  s1 val;
  return val;
}

This was bootstrapped for i686-pc-linux-gnu.
Regression tests run for stormy16-elf.

Okay to install?

Catherine

2001-09-20  Catherine Moore  <clm@redhat.com>

	* stmt.c (expand_value_return):  Pass the correct type
	to promote_mode.
	* c-common.c (type_for_mode):  Allow TImode in all cases.

Index: stmt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/stmt.c,v
retrieving revision 1.214
diff -p -r1.214 stmt.c
*** stmt.c	2001/08/27 17:36:20	1.214
--- stmt.c	2001/09/20 16:55:43
*************** expand_value_return (val)
*** 2889,2897 ****
  
    if (return_reg != val)
      {
!       tree type = TREE_TYPE (DECL_RESULT (current_function_decl));
  #ifdef PROMOTE_FUNCTION_RETURN
-       int unsignedp = TREE_UNSIGNED (type);
        enum machine_mode old_mode
  	= DECL_MODE (DECL_RESULT (current_function_decl));
        enum machine_mode mode
--- 2889,2898 ----
  
    if (return_reg != val)
      {
!       int unsignedp =
! 	  TREE_UNSIGNED (TREE_TYPE (DECL_RESULT (current_function_decl)));
!       tree type = type_for_mode (GET_MODE (return_reg), unsignedp);
  #ifdef PROMOTE_FUNCTION_RETURN
        enum machine_mode old_mode
  	= DECL_MODE (DECL_RESULT (current_function_decl));
        enum machine_mode mode
Index: c-common.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-common.c,v
retrieving revision 1.251
diff -p -r1.251 c-common.c
*** c-common.c	2001/09/15 19:47:38	1.251
--- c-common.c	2001/09/20 16:56:24
*************** type_for_mode (mode, unsignedp)
*** 1942,1951 ****
    if (mode == TYPE_MODE (intDI_type_node))
      return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
  
- #if HOST_BITS_PER_WIDE_INT >= 64
    if (mode == TYPE_MODE (intTI_type_node))
      return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
- #endif
  
    if (mode == TYPE_MODE (float_type_node))
      return float_type_node;
--- 1942,1949 ----


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