From e54b4cae03726bbceb7c25c8fdcf94bfcb549504 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 19 Dec 2002 18:06:46 +0100 Subject: [PATCH] re PR target/8340 (ICE on x86 inline asm w/ -fPIC) PR target/8340 * stmt.c (expand_asm_operands): Produce an error when the PIC register is clobbered. From-SVN: r60313 --- gcc/ChangeLog | 6 ++++++ gcc/stmt.c | 11 ++++++++++- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/i386-pic-1.c | 18 ++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/i386-pic-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 073b662e21d..eca6990f5a0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2002-12-19 Eric Botcazou + + PR target/8340 + * stmt.c (expand_asm_operands): Produce an error when + the PIC register is clobbered. + 2002-12-18 Daniel Berlin * Makefile.in (OBJS): Add alloc-pool.o diff --git a/gcc/stmt.c b/gcc/stmt.c index af0028fe5f7..2fc608c3730 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -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 (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d5f296f2d4a..cadf26ac95e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-12-19 Eric Botcazou + + * gcc.dg/i386-pic-1.c: New test. + 2002-12-18 Kriang Lerdsuwanakij 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 index 00000000000..4c548bf1cd6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/i386-pic-1.c @@ -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; +} -- 2.30.2