[PATCH] Fix debug/4461

Jakub Jelinek jakub@redhat.com
Wed Feb 20 09:50:00 GMT 2002


Hi!

The following testcase cannot link on IA-64 with -O -g,
because all references to -4.0L (.LC1) in the constant pool are optimized
away and thus it is not emitted at all.
I don't think it should be output into .rodata just because .debug_* wants
to reference it, because it would then be ALLOCed.
Ok to commit?

2002-02-20  Jakub Jelinek  <jakub@redhat.com>

	* 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.

--- gcc/testsuite/gcc.dg/debug/20020220-1.c.jj	Wed Feb 20 16:27:04 2002
+++ gcc/testsuite/gcc.dg/debug/20020220-1.c	Wed Feb 20 16:25:14 2002
@@ -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;
+}
--- gcc/varasm.c.jj	Tue Feb 19 11:13:31 2002
+++ gcc/varasm.c	Wed Feb 20 15:17:59 2002
@@ -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
--- gcc/rtl.h.jj	Tue Feb 19 11:13:31 2002
+++ gcc/rtl.h	Wed Feb 20 15:19:08 2002
@@ -1301,6 +1301,7 @@ extern rtx force_const_mem		PARAMS ((enu
 
 /* 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));
--- gcc/dwarf2out.c.jj	Wed Jan 30 12:17:55 2002
+++ gcc/dwarf2out.c	Wed Feb 20 16:06:45 2002
@@ -7801,10 +7801,22 @@ 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.  */
+	  if (!marked)
+	    return 0;
 	}
 
       mem_loc_result = new_loc_descr (DW_OP_addr, 0, 0);

	Jakub



More information about the Gcc-patches mailing list