re PR debug/4461 (Invalid dawrf2 debug code)
authorJakub Jelinek <jakub@redhat.com>
Wed, 20 Feb 2002 23:19:24 +0000 (00:19 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 20 Feb 2002 23:19:24 +0000 (00:19 +0100)
PR debug/4461
* varasm.c (get_pool_constant_mark): New.
* rtl.h (get_pool_constant_mark): Add prototype.
* dwarf2out.c (mem_loc_descriptor): A pool constant cannot
be represented if it has not been output.

* gcc.dg/debug/20020220-1.c: New test.

From-SVN: r49921

gcc/ChangeLog
gcc/dwarf2out.c
gcc/rtl.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/debug/20020220-1.c [new file with mode: 0644]
gcc/varasm.c

index 7a64a64af8aafb60d5815fe0e8653237abf5453f..7abdd710fb03adfc557ab7de57601546db8f8822 100644 (file)
@@ -1,3 +1,11 @@
+2002-02-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/4461
+       * varasm.c (get_pool_constant_mark): New.
+       * rtl.h (get_pool_constant_mark): Add prototype.
+       * dwarf2out.c (mem_loc_descriptor): A pool constant cannot
+       be represented if it has not been output.
+
 2002-02-20  Alexandre Oliva  <aoliva@redhat.com>
 
        * combine.c (do_SUBST): Sanity check substitutions of
index 4eb18c7c7a87e65d29ef9cd9f86e5608e4d69b18..f51df45d77bd2f012807ad18db92753cc3ad7b97 100644 (file)
@@ -7801,10 +7801,24 @@ mem_loc_descriptor (rtl, mode)
         by a different symbol.  */
       if (GET_CODE (rtl) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (rtl))
        {
-         rtx tmp = get_pool_constant (rtl);
+         bool marked;
+         rtx tmp = get_pool_constant_mark (rtl, &marked);
 
          if (GET_CODE (tmp) == SYMBOL_REF)
-           rtl = tmp;
+           {
+             rtl = tmp;
+             if (CONSTANT_POOL_ADDRESS_P (tmp))
+               get_pool_constant_mark (tmp, &marked);
+             else
+               marked = true;
+           }
+
+         /* If all references to this pool constant were optimized away,
+            it was not output and thus we can't represent it.
+            FIXME: might try to use DW_OP_const_value here, though
+            DW_OP_piece complicates it.  */
+         if (!marked)
+           return 0;
        }
 
       mem_loc_result = new_loc_descr (DW_OP_addr, 0, 0);
index 714faac91c694d50ec31cd099b69cdfe452088dd..c5b3397a355b70e4d2e61ce4ad2af9c12db2c029 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1301,6 +1301,7 @@ extern rtx force_const_mem                PARAMS ((enum machine_mode, rtx));
 
 /* In varasm.c  */
 extern rtx get_pool_constant           PARAMS ((rtx));
+extern rtx get_pool_constant_mark      PARAMS ((rtx, bool *));
 extern enum machine_mode get_pool_mode PARAMS ((rtx));
 extern rtx get_pool_constant_for_function      PARAMS ((struct function *, rtx));
 extern enum machine_mode get_pool_mode_for_function    PARAMS ((struct function *, rtx));
index faec271d2068ee63bb5b4e3a32b2dbfc0c9befea..a6653596fa66d0df012612ba4d7a653d67524949 100644 (file)
@@ -12,6 +12,8 @@
 
        * g++.dg/opt/ptrintsum1.C: New test.
 
+       * gcc.dg/debug/20020220-1.c: New test.
+
 2002-02-17  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.c-torture/execute/20020216-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/debug/20020220-1.c b/gcc/testsuite/gcc.dg/debug/20020220-1.c
new file mode 100644 (file)
index 0000000..07109e8
--- /dev/null
@@ -0,0 +1,31 @@
+/* PR debug/4461
+   This testcase failed to link in Dwarf-2 because
+   constant -4.0 in constant pool was never referenced by anything
+   but Dwarf-2 location descriptor.  */
+/* { dg-do run } */
+
+void __attribute__((noinline))
+foo (const char *x __attribute__((unused)),
+     __complex__ long double y __attribute__((unused)),
+     __complex__ long double z __attribute__((unused)))
+{
+}
+
+void
+bar (void)
+{
+  foo ("",
+       __builtin_conjl (({ __complex__ long double r;
+                          __real__ r = 3.0;
+                          __imag__ r = -4.0;
+                          r; })),
+       ({ __complex__ long double s;
+         __real__ s = 3.0;
+         __imag__ s = 4.0;
+         s; }));
+}
+
+int main (void)
+{
+  return 0;
+}
index 67d64e6263b69dfff00e96fdc88fc41386646797..46810c6833f4abda1589b534d9da82043132e117 100644 (file)
@@ -3900,6 +3900,19 @@ get_pool_constant (addr)
   return (find_pool_constant (cfun, addr))->constant;
 }
 
+/* Given a constant pool SYMBOL_REF, return the corresponding constant
+   and whether it has been output or not.  */
+
+rtx
+get_pool_constant_mark (addr, pmarked)
+     rtx addr;
+     bool *pmarked;
+{
+  struct pool_constant *pool = find_pool_constant (cfun, addr);
+  *pmarked = (pool->mark != 0);
+  return pool->constant;
+}
+
 /* Likewise, but for the constant pool of a specific function.  */
 
 rtx