This is the mail archive of the gcc@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]

Re: Ada miscompilation on mainline


Laurent GUERBY <guerby@acm.org> writes:

> On Sat, 2003-05-10 at 01:35, Zack Weinberg wrote:
>> Laurent GUERBY <guerby@acm.org> writes:
>> > Hi Zack, it looks like the problem I reported
>> > in <http://gcc.gnu.org/ml/gcc/2003-05/msg00609.html> 
>> > started to appear with the following patch:
>> I am not fluent in Ada.  Could you please attempt to reduce the test
>> case further?  In particular it would be nice if you could reproduce
>> the problem with a single unit with no 'with' statements, ideally <100
>> lines; then I have a chance of tracing what's going on.
>
> I was able to reduce it to a few lines, but not to one unit, may be
> this is because of inlining (but you need to compile
> only one unit to see the problem by looking at the assembly generated). 

Thank you.  I have a fix for the bug now.  The problem was that
integrate.c didn't tell varasm.c when it was copying the SYMBOL_REF
for .LC0 from q._init_proc into p, so varasm.c thought the constant
was unreferenced.  I didn't see this problem because there's no public
Ada test suite, and the C, C++, and Java front ends don't use
integrate.c for inlining.  While it was probably possible to trigger
the bug from Fortran, the Fortran test suite doesn't try very hard.

Would you please try the appended patch?

zw

        * varasm.c (notice_rtl_inlining_of_deferred_constant): New function.
        * rtl.h: Prototype it.
        * integrate.c (copy_rtx_and_substitute <SYMBOL_REF>): Call it
        when appropriate.

===================================================================
Index: integrate.c
--- integrate.c	3 May 2003 14:25:21 -0000	1.220
+++ integrate.c	13 May 2003 01:38:41 -0000
@@ -2215,6 +2215,8 @@ copy_rtx_and_substitute (orig, map, for_
 			  copy_rtx_and_substitute (constant, map, for_lhs)),
 			 0);
 	}
+      else if (DEFERRED_CONSTANT_P (orig) && inlining)
+	notice_rtl_inlining_of_deferred_constant ();
 
       return orig;
 
===================================================================
Index: varasm.c
--- varasm.c	12 May 2003 19:54:26 -0000	1.353
+++ varasm.c	13 May 2003 01:38:42 -0000
@@ -2672,6 +2672,15 @@ output_constant_def_contents (symbol)
 		   align);
 
 }
+
+/* A constant which was deferred in its original location has been
+   inserted by the RTL inliner into a different function.  The
+   current function's deferred constant count must be incremented.  */
+void
+notice_rtl_inlining_of_deferred_constant ()
+{
+  n_deferred_constants++;
+}
 
 /* Used in the hash tables to avoid outputting the same constant
    twice.  Unlike 'struct constant_descriptor_tree', RTX constants
===================================================================
Index: rtl.h
--- rtl.h	5 May 2003 21:57:48 -0000	1.403
+++ rtl.h	13 May 2003 01:38:42 -0000
@@ -1945,6 +1945,9 @@ extern rtx find_next_ref		PARAMS ((rtx, 
 
 extern rtx output_constant_def		PARAMS ((tree, int));
 
+/* Called from integrate.c when a deferred constant is inlined.  */
+extern void notice_rtl_inlining_of_deferred_constant PARAMS ((void));
+
 /* Define a default value for STORE_FLAG_VALUE.  */
 
 #ifndef STORE_FLAG_VALUE


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