/* In the normal case, the frame pointer is near the bottom of the frame
so we can do the full stack allocation and set it afterwards. There
- is an exception when the function accesses prior frames so, in this
- case, we need to pre-allocate a small chunk before setting it. */
- if (crtl->accesses_prior_frames)
- alloc_offset = seh->cfa_offset;
- else
+ is an exception if the function overflows the SEH maximum frame size
+ or accesses prior frames so, in this case, we need to pre-allocate a
+ small chunk of stack before setting it. */
+ offset = seh->sp_offset - INCOMING_FRAME_SP_OFFSET;
+ if (offset < SEH_MAX_FRAME_SIZE && !crtl->accesses_prior_frames)
alloc_offset = seh->sp_offset;
+ else
+ alloc_offset = MIN (seh->cfa_offset + 240, seh->sp_offset);
offset = alloc_offset - INCOMING_FRAME_SP_OFFSET;
- if (offset > 0 && offset < SEH_MAX_FRAME_SIZE)
+ if (offset > 0)
fprintf (f, "\t.seh_stackalloc\t" HOST_WIDE_INT_PRINT_DEC "\n", offset);
for (int regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
fprintf (f, ", " HOST_WIDE_INT_PRINT_DEC "\n", offset);
}
- if (crtl->accesses_prior_frames)
+ if (alloc_offset != seh->sp_offset)
{
offset = seh->sp_offset - alloc_offset;
if (offset > 0 && offset < SEH_MAX_FRAME_SIZE)
--- /dev/null
+-- { dg-do compile { target { lp64 || llp64 } } }
+-- { dg-options "-O2 -gnatws" }
+
+procedure Main is
+
+ subtype Int64 is Long_Long_Integer;
+
+ type Arr is array (Int64 range <>) of Boolean;
+
+ Pow : constant := 10;
+
+ procedure Compute (B : in out Arr) is
+ Factor : Int64 := 3;
+ Num : Int64;
+ begin
+ while Factor <= 10 ** (Pow / 2) loop
+ Num := Factor;
+ while Num < 10 ** Pow loop
+ if B (Num) then
+ Factor := Num;
+ exit;
+ end if;
+ Num := Num + 2;
+ end loop;
+ Num := Factor * Factor;
+ while Num < 10 ** Pow loop
+ B (Num) := False;
+ Num := Num + Factor * 2;
+ end loop;
+ Factor := Factor + 2;
+ end loop;
+ end;
+
+ B : Arr (1 .. 10 ** Pow) := (others => True);
+
+begin
+ Compute (B);
+end;