* [x86] Fix ICE with -fstack-check on Linux
@ 2012-11-09 9:14 Eric Botcazou
0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2012-11-09 9:14 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 681 bytes --]
This is a regression present on the mainline and 4.7 branch. The compiler
ICEs on the attached Ada testcase at -O -fstack-check in ix86_expand_prologue:
gcc_assert (m->fs.sp_offset == frame.stack_pointer_offset);
The problem is that release_scratch_register_on_entry uses a POP instruction
but doesn't update cfun->machine accordingly.
Tested on x86_64-suse-linux, applied on mainline and 4.7 branch as obvious.
2012-11-09 Eric Botcazou <ebotcazou@adacore.com>
* config/i386/i386.c (release_scratch_register_on_entry): Also adjust
sp_offset manually.
2012-11-09 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/stack_check3.ad[sb]: New test.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 748 bytes --]
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c (revision 193322)
+++ config/i386/i386.c (working copy)
@@ -9462,6 +9462,7 @@ release_scratch_register_on_entry (struc
{
if (sr->saved)
{
+ struct machine_function *m = cfun->machine;
rtx x, insn = emit_insn (gen_pop (sr->reg));
/* The RTX_FRAME_RELATED_P mechanism doesn't know about pop. */
@@ -9469,6 +9470,7 @@ release_scratch_register_on_entry (struc
x = gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (UNITS_PER_WORD));
x = gen_rtx_SET (VOIDmode, stack_pointer_rtx, x);
add_reg_note (insn, REG_FRAME_RELATED_EXPR, x);
+ m->fs.sp_offset -= UNITS_PER_WORD;
}
}
[-- Attachment #3: stack_check3.adb --]
[-- Type: text/x-adasrc, Size: 642 bytes --]
-- { dg-do compile }
-- { dg-options "-O -fstack-check" }
package body Stack_Check3 is
type Int_Arr is array (1 .. 34) of Integer;
type Rec (D : Boolean := False) is
record
case D is
when True => IA : Int_Arr;
when False => null;
end case;
end record;
type Rec_Arr is array (1 .. 256) of Rec;
protected Prot_Arr is
procedure Reset;
private
A : Rec_Arr;
end Prot_Arr;
protected body Prot_Arr is
procedure Reset is
begin
A := (others => (D => False));
end Reset;
end Prot_Arr;
procedure Reset is
begin
Prot_Arr.Reset;
end Reset;
end Stack_Check3;
[-- Attachment #4: stack_check3.ads --]
[-- Type: text/x-adasrc, Size: 63 bytes --]
package Stack_Check3 is
procedure Reset;
end Stack_Check3;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-11-09 9:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-09 9:14 [x86] Fix ICE with -fstack-check on Linux Eric Botcazou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).