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]

stack offset of local variable is not sign-extended to Pmode


This patch fixes a bug in function.c that causes the invalid pattern
(plus:HI (reg:HI) (const_int -32776)) to be generated.  Even though
Pmode is 16-bit HImode in this port, and the testcase
gcc.c-torture/compile/920501-4.c would arguably exceed the maximum
stack size, there's no for GCC to assume so and generate illegal RTL.
In fact, depending on the actual memory location of the stack, the
code and the heap, this testcase might actually work should it run,
since the stack size exceeds 32Kb but not 64Kb.  Ok to install?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva at redhat dot com>

	* function.c (assign_stack_local_1): Truncate constant added to
	frame_pointer_rtx or virtual_stack_vars_rtx for Pmode.

Index: gcc/function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.401
diff -u -p -r1.401 function.c
--- gcc/function.c 19 Feb 2003 18:03:07 -0000 1.401
+++ gcc/function.c 22 Feb 2003 10:10:37 -0000
@@ -1,6 +1,6 @@
 /* Expands front end tree to back end RTL for GNU C-Compiler
    Copyright (C) 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -586,11 +586,14 @@ assign_stack_local_1 (mode, size, align,
      address relative to the frame pointer.  */
   if (function == cfun && virtuals_instantiated)
     addr = plus_constant (frame_pointer_rtx,
+			  trunc_int_for_mode
 			  (frame_offset + bigend_correction
-			   + STARTING_FRAME_OFFSET));
+			   + STARTING_FRAME_OFFSET, Pmode));
   else
     addr = plus_constant (virtual_stack_vars_rtx,
-			  function->x_frame_offset + bigend_correction);
+			  trunc_int_for_mode
+			  (function->x_frame_offset + bigend_correction,
+			   Pmode));
 
 #ifndef FRAME_GROWS_DOWNWARD
   function->x_frame_offset += size;
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva at {redhat dot com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva at {lsd dot ic dot unicamp dot br, gnu.org}
Free Software Evangelist                Professional serial bug killer

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