This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch]: PR optimization/12209
- From: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: hubicka at gcc dot gnu dot org
- Date: Sat, 11 Oct 2003 14:25:51 +1000 (EST)
- Subject: [Patch]: PR optimization/12209
Hello,
The following patch fixes PR 12209. As discussed
in PR audit trail, the bug is specific to i386 targets that
probe the stack using code that clobbers eax. The
patch fixes by using the fastcall convention (use registers
ecx and edx, only, for passing function args) for
cgraph local function optimization when this stack probing
is enable.
I have bootstrapped (c/c++) and regtested on i686-pc-mingw32.
I have not been able to test the libgcj build because of
virtual memory limitations on my machine.
I will follow up with a patch to issue an error or warning
when the user specifies __attribute__((regparm(n))) and the
stack check code is engaged from the function prologue.
Danny
ChangeLog
2003-10-11 Danny Smith <dannysmith@users.sourceforge.net>
PR optimization/12209
* config/i386/i386.c (ix86_function_regparm): Return 2 for cgraph
local function optimization if TARGET_STACK_PROBE.
(init_cum_args): Set cum->fastcall for cgraph local function
optimization if TARGET_STACK_PROBE.
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.605
diff -c -3 -p -r1.605 i386.c
*** config/i386/i386.c 6 Oct 2003 23:18:31 -0000 1.605
--- config/i386/i386.c 11 Oct 2003 04:15:35 -0000
*************** ix86_function_regparm (tree type, tree d
*** 1699,1706 ****
if (i && i->local)
{
/* We can't use regparm(3) for nested functions as these use
! static chain pointer in third argument. */
! if (DECL_CONTEXT (decl) && !DECL_NO_STATIC_CHAIN (decl))
regparm = 2;
else
regparm = 3;
--- 1699,1708 ----
if (i && i->local)
{
/* We can't use regparm(3) for nested functions as these use
! static chain pointer in third argument.
! If maybe probing stack, eax is not available. */
! if ((DECL_CONTEXT (decl) && !DECL_NO_STATIC_CHAIN (decl))
! || TARGET_STACK_PROBE)
regparm = 2;
else
regparm = 3;
*************** init_cumulative_args (CUMULATIVE_ARGS *c
*** 1855,1860 ****
--- 1857,1874 ----
|| (fntype && !TYPE_ARG_TYPES (fntype)))
cum->maybe_vaarg = 1;
+ if (!TARGET_64BIT && TARGET_STACK_PROBE
+ && flag_unit_at_a_time
+ && !cum->fastcall && cum->nregs)
+ {
+ struct cgraph_local_info *i = cgraph_local_info (fndecl);
+ if (i && i->local)
+ {
+ cum->nregs = 2;
+ cum->fastcall = 1;
+ }
+ }
+
if (TARGET_DEBUG_ARG)
fprintf (stderr, ", nregs=%d )\n", cum->nregs);
http://search.yahoo.com.au - Yahoo! Search
- Looking for more? Try the new Yahoo! Search