fix execute/pure-1.c

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Tue Jun 18 14:20:00 GMT 2002


 > From: Richard Henderson <rth@redhat.com>
 > 
 > On Mon, Jun 03, 2002 at 11:03:15AM -0400, Kaveh R. Ghazi wrote:
 > > I don't understand.  Why are they deferred, and why does this only
 > > affect us at -O3 + noinline attribute?
 > 
 > They are deferred _because_ they are static.  We're waiting to see
 > if they're used at all.
 > 
 > > But what about platforms that are always pic, like mips-irix6?  The
 > > testcase would fail there by default (and in fact it does.)
 > 
 > The mips port should distinguish between pic code generation and
 > pic name resolution.  The alpha and ia64 ports (also "always pic")
 > do this for exactly these reasons.
 > 
 > > I think we're better off if we make everything static again and remove
 > > the noinline attribute so it passes at all opt levels on all platforms.
 > 
 > As you like.
 > r~

Sorry I sat on this.  This patch allows pure-1.c to succeed when used
on mips-irix6 (default flags) and on sparc-solaris2.7 (when adding
-fpic/-fPIC).  Ok to install?

		Thanks,
		--Kaveh


2002-06-18  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* gcc.c-torture/execute/pure-1.c: Make functions static again.

diff -rup orig/egcc-CVS20020612/gcc/testsuite/gcc.c-torture/execute/pure-1.c egcc-CVS20020612/gcc/testsuite/gcc.c-torture/execute/pure-1.c
--- orig/egcc-CVS20020612/gcc/testsuite/gcc.c-torture/execute/pure-1.c	2002-06-02 21:05:25.000000000 -0400
+++ egcc-CVS20020612/gcc/testsuite/gcc.c-torture/execute/pure-1.c	2002-06-13 15:04:32.212743478 -0400
@@ -17,20 +17,13 @@ extern int func0 (int) __attribute__ ((_
 extern int func1 (int) __attribute__ ((__const__));
 
 /* GCC should automatically detect attributes for these functions.
-   Don't allow -O3 to inline them.  */
-#define ANI __attribute__ ((__noinline__))
-
-/* ??? If we mark these static, then -O3 will defer them to the end of
-   compilation, and we won't have detected anything about them at the
-   point main is compiled.  Leaving them public works until someone runs
-   the testsuite with -fpic, or has an OS for which targetm.binds_local_p
-   returns false for some reason.  */
-int ANI func2 (int a) { return i + a; } /* pure */
-int ANI func3 (int a) { return a * 3; } /* const */
-int ANI func4 (int a) { return func0(a) + a; } /* pure */
-int ANI func5 (int a) { return a + func1(a); } /* const */
-int ANI func6 (int a) { return func2(a) + a; } /* pure */
-int ANI func7 (int a) { return a + func3(a); } /* const */
+   At -O3 They'll be inlined, but that's ok.  */
+static int func2 (int a) { return i + a; } /* pure */
+static int func3 (int a) { return a * 3; } /* const */
+static int func4 (int a) { return func0(a) + a; } /* pure */
+static int func5 (int a) { return a + func1(a); } /* const */
+static int func6 (int a) { return func2(a) + a; } /* pure */
+static int func7 (int a) { return a + func3(a); } /* const */
 
 int main ()
 {



More information about the Gcc-patches mailing list