PR inline-asm/11676
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 26 Jul 2003 15:53:14 +0000 (15:53 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 26 Jul 2003 15:53:14 +0000 (15:53 +0000)
        * cse.c (count_reg_usage): Handle asm_operands properly.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69816 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cse.c
gcc/testsuite/gcc.dg/asm-8.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/i386-asm-1.c [new file with mode: 0644]

index f1aaa6d..b2f7028 100644 (file)
@@ -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.
index a311be1..a4847a8 100644 (file)
--- 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 (file)
index 0000000..a3f3962
--- /dev/null
@@ -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 (file)
index 0000000..aae0de8
--- /dev/null
@@ -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;
+}