This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR target/8340
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 22 Nov 2002 17:28:33 +0100
- Subject: [PATCH] Fix PR target/8340
Hi,
The compiler ICEs on mainline (and silently generates illegal code on
gcc-3_2-branch) when compiling, in PIC mode, asm directives that clobber the
PIC register. Richard Henderson suggested that expand_asm_operands should
complain about the PIC register being clobbered instead (a much demanded
diagnostic, according to PR c/4106, PR c/6897 and PR c/8546).
Bootstrapped/regtested on i586-redhat-linux-gnu (c,c++,objc,f77 mainline).
OK to install ? What of gcc-3_2-branch ?
--
Eric Botcazou
2002-11-22 Eric Botcazou <ebotcazou@libertysurf.fr>
PR target/8340
* stmt.c (expand_asm_operands): Produces an error when
the PIC register is clobbered.
2002-11-22 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.dg/i386-pic-1.c: New test.
Index: stmt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stmt.c,v
retrieving revision 1.274
diff -u -r1.274 stmt.c
--- stmt.c 11 Nov 2002 21:25:25 -0000 1.274
+++ stmt.c 22 Nov 2002 14:47:34 -0000
@@ -1520,7 +1520,16 @@
/* Mark clobbered registers. */
if (i >= 0)
- SET_HARD_REG_BIT (clobbered_regs, i);
+ {
+ /* Clobbering the PIC register is an error */
+ if ((unsigned) i == PIC_OFFSET_TABLE_REGNUM)
+ {
+ error ("PIC register `%s' clobbered in `asm'", regname);
+ return;
+ }
+
+ SET_HARD_REG_BIT (clobbered_regs, i);
+ }
}
clear_last_expr ();
/* PR target/8340 */
/* { dg-do compile { target i?86-*-* } } */
/* { dg-options "-fPIC" } */
int foo ()
{
static int a;
__asm__ __volatile__ ( /* { dg-error "PIC register" } */
"xorl %%ebx, %%ebx\n"
"movl %%ebx, %0\n"
: "=m" (a)
:
: "%ebx"
);
return a;
}