diff mbox

: Fix very large frame bug on i386

Message ID F76CB096-C729-43BE-B9F7-E283804694B9@adacore.com
State New
Headers show

Commit Message

Tristan Gingold May 15, 2012, 9:10 a.m. UTC
Hi,

use of 'unsigned int' for i386.c:ix86_compute_frame_layout stack_alignment_needed results in truncation of frame offset in code such as:

 offset = (offset + stack_alignment_needed - 1) & -stack_alignment_needed

(as it is -stack_alignment_needed that is converted to HOST_WIDE_INT).

As a consequence, frames larger than 4GB are squeezed.

Also, the frame field of struct ix86_frame is never used.

Bootstrapped and reg-tested on x86_64 GNU/Linux, without regressions.

Ok for trunk ?

Tristan.

2012-05-15  Tristan Gingold  <gingold@adacore.com>

	* config/i386/i386.c (struct ix86_frame): Remove unused frame field.
	(ix86_compute_frame_layout): Fix type of stack_alignment_needed
	and preferred_alignment.

Comments

Tristan Gingold May 21, 2012, 11:55 a.m. UTC | #1
Ping for:

On May 15, 2012, at 11:10 AM, Tristan Gingold wrote:

> Hi,
> 
> use of 'unsigned int' for i386.c:ix86_compute_frame_layout stack_alignment_needed results in truncation of frame offset in code such as:
> 
> offset = (offset + stack_alignment_needed - 1) & -stack_alignment_needed
> 
> (as it is -stack_alignment_needed that is converted to HOST_WIDE_INT).
> 
> As a consequence, frames larger than 4GB are squeezed.
> 
> Also, the frame field of struct ix86_frame is never used.
> 
> Bootstrapped and reg-tested on x86_64 GNU/Linux, without regressions.
> 
> Ok for trunk ?
> 
> Tristan.
> 
> 2012-05-15  Tristan Gingold  <gingold@adacore.com>
> 
> 	* config/i386/i386.c (struct ix86_frame): Remove unused frame field.
> 	(ix86_compute_frame_layout): Fix type of stack_alignment_needed
> 	and preferred_alignment.
> 
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index ad4739b..353ee53 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -2408,7 +2408,6 @@ struct ix86_frame
>   int va_arg_size;
>   int red_zone_size;
>   int outgoing_arguments_size;
> -  HOST_WIDE_INT frame;
> 
>   /* The offsets relative to ARG_POINTER.  */
>   HOST_WIDE_INT frame_pointer_offset;
> @@ -8937,9 +8936,9 @@ ix86_builtin_setjmp_frame_value (void)
> static void
> ix86_compute_frame_layout (struct ix86_frame *frame)
> {
> -  unsigned int stack_alignment_needed;
> +  unsigned HOST_WIDE_INT stack_alignment_needed;
>   HOST_WIDE_INT offset;
> -  unsigned int preferred_alignment;
> +  unsigned HOST_WIDE_INT preferred_alignment;
>   HOST_WIDE_INT size = get_frame_size ();
>   HOST_WIDE_INT to_allocate;
> 
>
Richard Henderson May 22, 2012, 5:17 p.m. UTC | #2
On 05/15/12 02:10, Tristan Gingold wrote:
> 2012-05-15  Tristan Gingold  <gingold@adacore.com>
> 
> 	* config/i386/i386.c (struct ix86_frame): Remove unused frame field.
> 	(ix86_compute_frame_layout): Fix type of stack_alignment_needed
> 	and preferred_alignment.

Ok with a test case.  Even if it's a scan-assember sort of test.


r~
Tristan Gingold May 25, 2012, 8:59 a.m. UTC | #3
On May 22, 2012, at 7:17 PM, Richard Henderson wrote:

> On 05/15/12 02:10, Tristan Gingold wrote:
>> 2012-05-15  Tristan Gingold  <gingold@adacore.com>
>> 
>> 	* config/i386/i386.c (struct ix86_frame): Remove unused frame field.
>> 	(ix86_compute_frame_layout): Fix type of stack_alignment_needed
>> 	and preferred_alignment.
> 
> Ok with a test case.  Even if it's a scan-assember sort of test.

Thanks, now committed with the following testcase:

/* { dg-do compile } */
/* { dg-require-effective-target lp64 } */
/* { dg-final { scan-assembler "-429496" } } */
extern void dump (int *buf, int a);

void func (int a)
{
  int bigbuf[1 << 30];
  dump (bigbuf, a);
}


Tristan.
diff mbox

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index ad4739b..353ee53 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2408,7 +2408,6 @@  struct ix86_frame
   int va_arg_size;
   int red_zone_size;
   int outgoing_arguments_size;
-  HOST_WIDE_INT frame;
 
   /* The offsets relative to ARG_POINTER.  */
   HOST_WIDE_INT frame_pointer_offset;
@@ -8937,9 +8936,9 @@  ix86_builtin_setjmp_frame_value (void)
 static void
 ix86_compute_frame_layout (struct ix86_frame *frame)
 {
-  unsigned int stack_alignment_needed;
+  unsigned HOST_WIDE_INT stack_alignment_needed;
   HOST_WIDE_INT offset;
-  unsigned int preferred_alignment;
+  unsigned HOST_WIDE_INT preferred_alignment;
   HOST_WIDE_INT size = get_frame_size ();
   HOST_WIDE_INT to_allocate;