re PR target/8340 (ICE on x86 inline asm w/ -fPIC)
authorEric Botcazou <ebotcazou@libertysurf.fr>
Thu, 19 Dec 2002 17:06:46 +0000 (18:06 +0100)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 19 Dec 2002 17:06:46 +0000 (17:06 +0000)
PR target/8340
* stmt.c (expand_asm_operands): Produce an error when
the PIC register is clobbered.

From-SVN: r60313

gcc/ChangeLog
gcc/stmt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/i386-pic-1.c [new file with mode: 0644]

index 073b662e21db3aed49d23ded5e864c680ca4c56c..eca6990f5a0b74f9edcb8adc2ab1b6025c8c9367 100644 (file)
@@ -1,3 +1,9 @@
+2002-12-19  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       PR target/8340
+       * stmt.c (expand_asm_operands): Produce an error when
+       the PIC register is clobbered.
+
 2002-12-18  Daniel Berlin  <dberlin@dberlin.org>
 
        * Makefile.in (OBJS): Add alloc-pool.o
index af0028fe5f729a1a090d3263bed1c4b8117e1101..2fc608c373014fc34ebac84649eadfc0e9e12c42 100644 (file)
@@ -1509,7 +1509,16 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
 
       /* 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 ();
index d5f296f2d4a3c281de0a5684bd6778e38f9906ef..cadf26ac95e862b6b2ed216d9cc1d03b58e72c97 100644 (file)
@@ -1,3 +1,7 @@
+2002-12-19  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       * gcc.dg/i386-pic-1.c: New test.
+
 2002-12-18  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        PR c++/8099
diff --git a/gcc/testsuite/gcc.dg/i386-pic-1.c b/gcc/testsuite/gcc.dg/i386-pic-1.c
new file mode 100644 (file)
index 0000000..4c548bf
--- /dev/null
@@ -0,0 +1,18 @@
+/* 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;
+}