This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fix ia64-hpux deferred_symbol_p failure


On Mon, May 12, 2003 at 01:54:29PM -0700, Steve Ellcey wrote:
>         .section        .rodata,        "a",    "progbits"
>         .align 8
>   .LC0:
>         stringz "hi"
>         .align 8
>   .LC0:
>         stringz "hi"

This is fallout from 

2003-05-05  Zack Weinberg  <zack@codesourcery.com>

        * rtl.h (STRING_POOL_ADDRESS_P): Rename to DEFERRED_CONSTANT_P.
        * varasm.c (struct varasm_status): Add deferred_constants field.
	...

> If I compile in 64 bit mode, this goes away.

Zack relied on SYMBOL_REF objects being unique for any object.  This is
unfortunately not true.  The duplicate created by this test case is for

#2  0x40000000003c4740 in convert_memory_address (to_mode=SImode, 
    x=0x2000000000388320) at ../../../src-gcc/gcc/explow.c:410
409         case SYMBOL_REF:
410           temp = shallow_copy_rtx (x);
411           PUT_MODE (temp, to_mode);
412           return temp;

I.e. this duplication problem should ocurr only on targets with 
Pmode != ptr_mode, which is why Zack didn't see it.

I believe we can instead rely on the tree constant object being 
unique, since that pointer will be duplicated by the shallow copy.
Which would allow us to use TREE_ASM_WRITTEN, which seems equally
natural.

Try the following.


r~


	* rtl.h (TREE_CONSTANT_POOL_ADDRESS_P): New.
	(DEFERRED_CONSTANT_P): Remove.
	* varasm.c (build_constant_desc): Set it.
	(maybe_output_constant_def_contents): Check TREE_ASM_WRITTEN to
	see if we've already output this constant.
	(output_constant_def_contents): Set TREE_ASM_WRITTEN.
	(mark_constant): Check it before calling output_constant_def_contents.

Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.403
diff -u -p -u -r1.403 rtl.h
--- rtl.h	5 May 2003 21:57:48 -0000	1.403
+++ rtl.h	12 May 2003 23:03:19 -0000
@@ -1230,15 +1230,16 @@ do {						\
 #define COND_EXEC_TEST(RTX) XCEXP (RTX, 0, COND_EXEC)
 #define COND_EXEC_CODE(RTX) XCEXP (RTX, 1, COND_EXEC)
 
-/* 1 if RTX is a symbol_ref that addresses this function's constants pool.  */
+/* 1 if RTX is a symbol_ref that addresses this function's rtl
+   constants pool.  */
 #define CONSTANT_POOL_ADDRESS_P(RTX)					\
   (RTL_FLAG_CHECK1("CONSTANT_POOL_ADDRESS_P", (RTX), SYMBOL_REF)->unchanging)
 
-/* 1 if RTX is a symbol_ref that addresses a value in the file's constant
-   pool which has not yet been output.  This information is private to
-   varasm.c.  */
-#define DEFERRED_CONSTANT_P(RTX)					\
-  (RTL_FLAG_CHECK1("DEFERRED_CONSTANT_P", (RTX), SYMBOL_REF)->frame_related)
+/* 1 if RTX is a symbol_ref that addresses a value in the file's
+   tree constant pool.  This information is private to varasm.c.  */
+#define TREE_CONSTANT_POOL_ADDRESS_P(RTX)				\
+  (RTL_FLAG_CHECK1("TREE_CONSTANT_POOL_ADDRESS_P",			\
+		   (RTX), SYMBOL_REF)->frame_related)
 
 /* Used if RTX is a symbol_ref, for machine-specific purposes.  */
 #define SYMBOL_REF_FLAG(RTX)						\
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.353
diff -u -p -u -r1.353 varasm.c
--- varasm.c	12 May 2003 19:54:26 -0000	1.353
+++ varasm.c	12 May 2003 23:03:19 -0000
@@ -2536,6 +2536,7 @@ build_constant_desc (exp)
   symbol = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (label));
   SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_LOCAL;
   SYMBOL_REF_DECL (symbol) = exp;
+  TREE_CONSTANT_POOL_ADDRESS_P (symbol) = 1;
 
   rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)), symbol);
   set_mem_attributes (rtl, exp, 1);
@@ -2550,12 +2551,6 @@ build_constant_desc (exp)
 
   (*targetm.encode_section_info) (exp, rtl, true);
 
-  /* Descriptors start out deferred; this simplifies the logic in
-     maybe_output_constant_def_contents.  However, we do not bump
-     n_deferred_constants here, because we don't know if we're inside
-     a function and have an n_deferred_constants to bump.  */
-  DEFERRED_CONSTANT_P (XEXP (rtl, 0)) = 1;
-
   desc->rtl = rtl;
 
   return desc;
@@ -2607,19 +2602,24 @@ maybe_output_constant_def_contents (desc
      int defer;
 {
   rtx symbol = XEXP (desc->rtl, 0);
+  tree exp = desc->value;
 
   if (flag_syntax_only)
     return;
 
-  if (!DEFERRED_CONSTANT_P (symbol))
+  if (TREE_ASM_WRITTEN (exp))
     /* Already output; don't do it again.  */
     return;
 
   /* The only constants that cannot safely be deferred, assuming the
      context allows it, are strings under flag_writable_strings.  */
-  if (defer && (TREE_CODE (desc->value) != STRING_CST
-		|| !flag_writable_strings))
+  if (defer && (TREE_CODE (exp) != STRING_CST || !flag_writable_strings))
     {
+      /* Increment n_deferred_constants if it exists.  It needs to be at
+	 least as large as the number of constants actually referred to
+	 by the function.  If it's too small we'll stop looking too early
+	 and fail to emit constants; if it's too large we'll only look
+	 through the entire function when we could have stopped earlier.  */
       if (cfun)
 	n_deferred_constants++;
       return;
@@ -2648,7 +2648,7 @@ output_constant_def_contents (symbol)
 #endif
 
   /* We are no longer deferring this constant.  */
-  DEFERRED_CONSTANT_P (symbol) = 0;
+  TREE_ASM_WRITTEN (exp) = 1;
 
   if (IN_NAMED_SECTION (exp))
     named_section (exp, NULL, reloc);
@@ -3472,10 +3472,14 @@ mark_constant (current_rtx, data)
 	  else
 	    return -1;
 	}
-      else if (DEFERRED_CONSTANT_P (x))
+      else if (TREE_CONSTANT_POOL_ADDRESS_P (x))
 	{
-	  n_deferred_constants--;
-	  output_constant_def_contents (x);
+	  tree exp = SYMBOL_REF_DECL (x);
+	  if (!TREE_ASM_WRITTEN (exp))
+	    {
+	      n_deferred_constants--;
+	      output_constant_def_contents (x);
+	    }
 	}
     }
   return 0;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]