This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/21518] [4.0/4.1 Regression] unable to find a register to spill in class 'Q_REGS' with -fPIC and -O2
- From: "steven at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Oct 2005 21:55:37 -0000
- Subject: [Bug target/21518] [4.0/4.1 Regression] unable to find a register to spill in class 'Q_REGS' with -fPIC and -O2
- References: <bug-21518-10616@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #9 from steven at gcc dot gnu dot org 2005-10-07 21:55 -------
I guess something like this should work if Andrew was right in comment #6.
Obviously this doesn't fix the the test case from comment #1 because we
don't go through this code if a user codes an "attribute regparm".
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.862
diff -u -3 -p -r1.862 i386.c
--- config/i386/i386.c 5 Oct 2005 18:19:25 -0000 1.862
+++ config/i386/i386.c 7 Oct 2005 21:41:41 -0000
@@ -2171,10 +2171,13 @@ ix86_function_regparm (tree type, tree d
if (global_regs[local_regparm])
break;
/* We can't use regparm(3) for nested functions as these use
- static chain pointer in third argument. */
+ static chain pointer in third argument. We also can't use
+ it when we are producing PIC code because one register is
+ reserved for the GOT (see e.g. PR21518). */
if (local_regparm == 3
- && decl_function_context (decl)
- && !DECL_NO_STATIC_CHAIN (decl))
+ && ((decl_function_context (decl)
+ && !DECL_NO_STATIC_CHAIN (decl))
+ || flag_pic))
local_regparm = 2;
/* Each global register variable increases register preassure,
so the more global reg vars there are, the smaller regparm
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21518