aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2003-07-26 08:53:14 -0700
committerRichard Henderson <rth@gcc.gnu.org>2003-07-26 08:53:14 -0700
commita6c14a644cb2a52baecf1f74d128297352fd360d (patch)
tree2004ca3e22c09d34da7b9b5d3effeba065873fd5
parentcd65f08202a73d0f3cbe11b13e0e279ed2f25fbb (diff)
downloadgcc-a6c14a644cb2a52baecf1f74d128297352fd360d.zip
gcc-a6c14a644cb2a52baecf1f74d128297352fd360d.tar.gz
gcc-a6c14a644cb2a52baecf1f74d128297352fd360d.tar.bz2
re PR inline-asm/11676 (operand to volatile asm incorrectly removed)
PR inline-asm/11676 * cse.c (count_reg_usage): Handle asm_operands properly. From-SVN: r69816
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/cse.c10
-rw-r--r--gcc/testsuite/gcc.dg/asm-8.c9
-rw-r--r--gcc/testsuite/gcc.dg/i386-asm-1.c24
4 files changed, 48 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f1aaa6d..b2f7028 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2003-07-26 Richard Henderson <rth@redhat.com>
+
+ PR inline-asm/11676
+ * cse.c (count_reg_usage): Handle asm_operands properly.
+
2003-07-26 Roger Sayle <roger@eyesopen.com>
* builtins.def (DEF_FALLBACK_BUILTIN): Delete.
diff --git a/gcc/cse.c b/gcc/cse.c
index a311be1..a4847a8 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -7384,6 +7384,16 @@ count_reg_usage (rtx x, int *counts, rtx dest, int incr)
count_reg_usage (XEXP (x, 1), counts, NULL_RTX, incr);
return;
+ case ASM_OPERANDS:
+ /* If the asm is volatile, then this insn cannot be deleted,
+ and so the inputs *must* be live. */
+ if (MEM_VOLATILE_P (x))
+ dest = NULL_RTX;
+ /* Iterate over just the inputs, not the constraints as well. */
+ for (i = ASM_OPERANDS_INPUT_LENGTH (x) - 1; i >= 0; i--)
+ count_reg_usage (ASM_OPERANDS_INPUT (x, i), counts, dest, incr);
+ return;
+
case INSN_LIST:
abort ();
diff --git a/gcc/testsuite/gcc.dg/asm-8.c b/gcc/testsuite/gcc.dg/asm-8.c
new file mode 100644
index 0000000..a3f3962e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asm-8.c
@@ -0,0 +1,9 @@
+/* PR inline-asm/11676 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wall" } */
+
+void foo(void)
+{
+ long x = 0;
+ asm volatile ("" : "=r"(x) : "r"(x)); /* { dg-bogus "uninitialized" } */
+}
diff --git a/gcc/testsuite/gcc.dg/i386-asm-1.c b/gcc/testsuite/gcc.dg/i386-asm-1.c
new file mode 100644
index 0000000..aae0de8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/i386-asm-1.c
@@ -0,0 +1,24 @@
+/* PR inline-asm/11676 */
+/* { dg-do run { target i?86-*-* } } */
+/* { dg-options "-O2" } */
+
+static int bar(int x) __asm__("bar");
+static int __attribute__((regparm(1), noinline, used))
+bar(int x)
+{
+ if (x != 0)
+ abort ();
+}
+
+static int __attribute__((regparm(1), noinline))
+foo(int x)
+{
+ x = 0;
+ __asm__ __volatile__("call bar" : "=a"(x) : "a"(x));
+}
+
+int main()
+{
+ foo(1);
+ return 0;
+}