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]

[lto] Run some testsuites with LTO if it's available


Janis,

Does this look OK for supporting LTO only when it's available?
Initially I wanted to always add -flto if it was available, but
there may be other reasons why a testsuite would not want LTO, so
it needs to be merged in by each .exp file.


Thanks.  Diego.

gcc/ChangeLog.lto

2009-05-19  Diego Novillo  <dnovillo@google.com>

	* opts.c (complain_wrong_lang): Remove workaround to
	quell warning message when LTO is not supported.


gcc/testsuite/ChangeLog.lto

2009-05-19  Diego Novillo  <dnovillo@google.com>

	* lib/target-supports.exp (check_effective_target_lto): New.
	* lib/c-torture.exp: Call it to set LTO_TORTURE_OPTIONS.
	* lib/gcc-dg.exp: Likewise.
	* gcc.c-torture/execute/execute.exp: Add LTO_TORTURE_OPTIONS
	when calling set-torture-options.
	* gcc.c-torture/execute/builtins/builtins.exp: Likewise.
	* gcc.c-torture/execute/ieee/ieee.exp: Likewise.
	* gcc.c-torture/unsorted/unsorted.exp: Likewise.
	* gcc.target/i386/math-torture/math-torture.exp: Likewise.
	* gcc.target/x86_64/abi/abi-x86_64.exp: Likewise.
	* gcc.target/x86_64/abi/avx/abi-avx.exp: Likewise.
	* gcc.misc-tests/i386-prefetch.exp: Likewise.
	* gcc.misc-tests/dectest.exp: Likewise.

libstdc++-v3/ChangeLog.lto

2009-05-19  Diego Novillo  <dnovillo@google.com>

	* libstdc++-v3/scripts/testsuite_flags.in: Do not always
	add -fwhopr.
	* libstdc++-v3/testsuite/lib/libstdc++.exp: Call
	check_effective_target_lto to determine if -fwhopr should
	be added.

Index: gcc/testsuite/gcc.c-torture/execute/execute.exp
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/execute.exp	(revision 147597)
+++ gcc/testsuite/gcc.c-torture/execute/execute.exp	(working copy)
@@ -32,7 +32,7 @@ load_lib torture-options.exp
 load_lib c-torture.exp

 torture-init
-set-torture-options $C_TORTURE_OPTIONS
+set-torture-options $C_TORTURE_OPTIONS $LTO_TORTURE_OPTIONS

 #
 # main test loop
Index: gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp	(revision 147597)
+++ gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp	(working copy)
@@ -35,7 +35,7 @@ load_lib torture-options.exp
 load_lib c-torture.exp

 torture-init
-set-torture-options $C_TORTURE_OPTIONS
+set-torture-options $C_TORTURE_OPTIONS $LTO_TORTURE_OPTIONS

 set additional_flags ""
 if [istarget "powerpc-*-darwin*"] {
Index: gcc/testsuite/gcc.c-torture/execute/ieee/ieee.exp
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/ieee/ieee.exp	(revision 147597)
+++ gcc/testsuite/gcc.c-torture/execute/ieee/ieee.exp	(working copy)
@@ -35,7 +35,7 @@ if $tracelevel then {
 }

 torture-init
-set-torture-options $C_TORTURE_OPTIONS
+set-torture-options $C_TORTURE_OPTIONS $LTO_TORTURE_OPTIONS

 set additional_flags ""

Index: gcc/testsuite/gcc.c-torture/unsorted/unsorted.exp
===================================================================
--- gcc/testsuite/gcc.c-torture/unsorted/unsorted.exp	(revision 147597)
+++ gcc/testsuite/gcc.c-torture/unsorted/unsorted.exp	(working copy)
@@ -33,7 +33,7 @@ load_lib c-torture.exp
 load_lib torture-options.exp

 torture-init
-set-torture-options $C_TORTURE_OPTIONS
+set-torture-options $C_TORTURE_OPTIONS $LTO_TORTURE_OPTIONS

 #
 # This loop will run c-torture on any *.c file found in this directory.
Index: gcc/testsuite/gcc.target/i386/math-torture/math-torture.exp
===================================================================
--- gcc/testsuite/gcc.target/i386/math-torture/math-torture.exp	(revision
147597)
+++ gcc/testsuite/gcc.target/i386/math-torture/math-torture.exp	(working copy)
@@ -52,7 +52,7 @@ load_lib gcc-dg.exp
 load_lib torture-options.exp

 torture-init
-set-torture-options $MATH_TORTURE_OPTIONS
+set-torture-options $MATH_TORTURE_OPTIONS $LTO_TORTURE_OPTIONS

 dg-init
 gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] ""
Index: gcc/testsuite/gcc.target/x86_64/abi/abi-x86_64.exp
===================================================================
--- gcc/testsuite/gcc.target/x86_64/abi/abi-x86_64.exp	(revision 147597)
+++ gcc/testsuite/gcc.target/x86_64/abi/abi-x86_64.exp	(working copy)
@@ -28,7 +28,7 @@ if { (![istarget x86_64-*-*] && ![istarg


 torture-init
-set-torture-options $C_TORTURE_OPTIONS
+set-torture-options $C_TORTURE_OPTIONS $LTO_TORTURE_OPTIONS
 set additional_flags "-W -Wall -Wno-abi"

 foreach src [lsort [glob -nocomplain $srcdir/$subdir/test_*.c]] {
Index: gcc/testsuite/gcc.target/x86_64/abi/avx/abi-avx.exp
===================================================================
--- gcc/testsuite/gcc.target/x86_64/abi/avx/abi-avx.exp	(revision 147597)
+++ gcc/testsuite/gcc.target/x86_64/abi/avx/abi-avx.exp	(working copy)
@@ -29,7 +29,7 @@ if { (![istarget x86_64-*-*] && ![istarg


 torture-init
-set-torture-options $C_TORTURE_OPTIONS
+set-torture-options $C_TORTURE_OPTIONS $LTO_TORTURE_OPTIONS
 set additional_flags "-W -Wall -mavx"

 foreach src [lsort [glob -nocomplain $srcdir/$subdir/test_*.c]] {
Index: gcc/testsuite/gcc.misc-tests/i386-prefetch.exp
===================================================================
--- gcc/testsuite/gcc.misc-tests/i386-prefetch.exp	(revision 147597)
+++ gcc/testsuite/gcc.misc-tests/i386-prefetch.exp	(working copy)
@@ -90,16 +90,16 @@ load_lib torture-options.exp
 dg-init
 torture-init

-set-torture-options $PREFETCH_NONE
+set-torture-options $PREFETCH_NONE $LTO_TORTURE_OPTIONS
 gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-none-*.c]] ""

-set-torture-options $PREFETCH_SSE
+set-torture-options $PREFETCH_SSE $LTO_TORTURE_OPTIONS
 gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-sse-*.c]] ""

-set-torture-options $PREFETCH_3DNOW
+set-torture-options $PREFETCH_3DNOW $LTO_TORTURE_OPTIONS
 gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-3dnow-*.c]] ""

-set-torture-options $PREFETCH_ATHLON
+set-torture-options $PREFETCH_ATHLON $LTO_TORTURE_OPTIONS
 gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-athlon-*.c]] ""

 torture-finish
Index: gcc/testsuite/gcc.misc-tests/dectest.exp
===================================================================
--- gcc/testsuite/gcc.misc-tests/dectest.exp	(revision 147597)
+++ gcc/testsuite/gcc.misc-tests/dectest.exp	(working copy)
@@ -518,7 +518,7 @@ if [catch {set testdir $env(DECTEST)}] {
 }

 torture-init
-set-torture-options $DEC_TORTURE_OPTIONS
+set-torture-options $DEC_TORTURE_OPTIONS $LTO_TORTURE_OPTIONS

 note "Using tests in $testdir"
 dfp-run-tests [lsort [glob -nocomplain $testdir/*.decTest]]
Index: gcc/testsuite/lib/c-torture.exp
===================================================================
--- gcc/testsuite/lib/c-torture.exp	(revision 147597)
+++ gcc/testsuite/lib/c-torture.exp	(working copy)
@@ -17,6 +17,7 @@

 # This file was written by Rob Savoye. (rob@cygnus.com)

+load_lib target-supports.exp
 load_lib file-format.exp
 load_lib target-libpath.exp

@@ -34,16 +35,14 @@ if [info exists TORTURE_OPTIONS] {
     # items below, even though -O3 is also specified, because some ports may
     # choose to disable inlining functions by default, even when optimizing.
     set C_TORTURE_OPTIONS [list \
-	{ -O0 -flto } \
-	{ -O0 -fwhopr } \
-	{ -O1 -flto } \
-	{ -O2 -flto } \
-	{ -O2 -fwhopr } \
-	{ -O3 -flto -fomit-frame-pointer } \
-	{ -O3 -flto -fomit-frame-pointer -funroll-loops } \
-	{ -O3 -flto -fomit-frame-pointer -funroll-all-loops -finline-functions } \
+	{ -O0 } \
+	{ -O1 } \
+	{ -O2 } \
+	{ -O3 -fomit-frame-pointer } \
+	{ -O3 -fomit-frame-pointer -funroll-loops } \
+	{ -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions } \
 	{ -O3 -g } \
-	{ -Os -flto } ]
+	{ -Os } ]
 }

 if [info exists ADDITIONAL_TORTURE_OPTIONS] {
@@ -51,6 +50,11 @@ if [info exists ADDITIONAL_TORTURE_OPTIO
 	[concat $C_TORTURE_OPTIONS $ADDITIONAL_TORTURE_OPTIONS]
 }

+set LTO_TORTURE_OPTIONS ""
+if [check_effective_target_lto] {
+    set LTO_TORTURE_OPTIONS [list {} {-flto} {-fwhopr}]
+}
+
 global GCC_UNDER_TEST
 if ![info exists GCC_UNDER_TEST] {
     set GCC_UNDER_TEST "[find_gcc]"
Index: gcc/testsuite/lib/gcc-dg.exp
===================================================================
--- gcc/testsuite/lib/gcc-dg.exp	(revision 147597)
+++ gcc/testsuite/lib/gcc-dg.exp	(working copy)
@@ -45,16 +45,14 @@ if [info exists TORTURE_OPTIONS] {
     # items below, even though -O3 is also specified, because some ports may
     # choose to disable inlining functions by default, even when optimizing.
     set DG_TORTURE_OPTIONS [list \
-	{ -O0 -flto } \
-	{ -O0 -fwhopr } \
-	{ -O1 -flto } \
-	{ -O2 -flto } \
-	{ -O2 -fwhopr } \
-	{ -O3 -flto -fomit-frame-pointer } \
-	{ -O3 -flto -fomit-frame-pointer -funroll-loops } \
-	{ -O3 -flto -fomit-frame-pointer -funroll-all-loops -finline-functions } \
+	{ -O0 } \
+	{ -O1 } \
+	{ -O2 } \
+	{ -O3 -fomit-frame-pointer } \
+	{ -O3 -fomit-frame-pointer -funroll-loops } \
+	{ -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions } \
 	{ -O3 -g } \
-	{ -Os -flto } ]
+	{ -Os } ]
 }

 if [info exists ADDITIONAL_TORTURE_OPTIONS] {
@@ -62,6 +60,11 @@ if [info exists ADDITIONAL_TORTURE_OPTIO
 	[concat $DG_TORTURE_OPTIONS $ADDITIONAL_TORTURE_OPTIONS]
 }

+set LTO_TORTURE_OPTIONS ""
+if [check_effective_target_lto] {
+    set LTO_TORTURE_OPTIONS [list {} {-flto} {-fwhopr}]
+}
+
 global GCC_UNDER_TEST
 if ![info exists GCC_UNDER_TEST] {
     set GCC_UNDER_TEST "[find_gcc]"
@@ -245,7 +248,7 @@ proc gcc-dg-runtest { testcases default-
     if { $existing_torture_options == 0 } {
 	global DG_TORTURE_OPTIONS
 	torture-init
-	set-torture-options $DG_TORTURE_OPTIONS
+	set-torture-options $DG_TORTURE_OPTIONS $LTO_TORTURE_OPTIONS
     }
     dump-torture-options

Index: gcc/testsuite/lib/target-supports.exp
===================================================================
--- gcc/testsuite/lib/target-supports.exp	(revision 147597)
+++ gcc/testsuite/lib/target-supports.exp	(working copy)
@@ -2925,3 +2925,12 @@ proc check_effective_target_correct_iso_
 	#endif
     }]
 }
+
+# Return 1 if the compiler has been configure with link-time optimization
+# (LTO) support.
+
+proc check_effective_target_lto { } {
+    return [check_no_compiler_messages lto executable {
+	int main (void) { return 0; }
+    } "-O0 -flto"]
+}
Index: gcc/opts.c
===================================================================
--- gcc/opts.c	(revision 147597)
+++ gcc/opts.c	(working copy)
@@ -441,12 +441,6 @@ complain_wrong_lang (const char *text, c
   if (lang_mask & CL_LTO)
     return;

-  /* FIXME lto.  Hack.  Do not merge.  This merely hides this warning
-     to avoid spurious failures in non-C/C++ testsuites.  It would be
-     much better to fix the testsuites.  */
-  if (option->flag_var == &flag_lto || option->flag_var == &flag_whopr)
-    return;
-
   ok_langs = write_langs (option->flags);
   bad_lang = write_langs (lang_mask);

Index: libstdc++-v3/scripts/testsuite_flags.in
===================================================================
--- libstdc++-v3/scripts/testsuite_flags.in	(revision 147493)
+++ libstdc++-v3/scripts/testsuite_flags.in	(working copy)
@@ -54,12 +54,12 @@ case ${query} in
       echo ${CC}
       ;;
     --cxxflags)
-      CXXFLAGS_default="-O2 -fwhopr -D_GLIBCXX_ASSERT -fmessage-length=0"
+      CXXFLAGS_default="-g -O2 -D_GLIBCXX_ASSERT -fmessage-length=0"
       CXXFLAGS_config="@SECTION_FLAGS@ @CXXFLAGS@ @EXTRA_CXX_FLAGS@"
       echo ${CXXFLAGS_default} ${CXXFLAGS_config}
       ;;
     --cxxparallelflags)
-      CXXFLAGS_parallel="-fwhopr -D_GLIBCXX_PARALLEL -fopenmp
+      CXXFLAGS_parallel="-D_GLIBCXX_PARALLEL -fopenmp
 			 -B${BUILD_DIR}/../libgomp
                          -I${BUILD_DIR}/../libgomp
 			 -L${BUILD_DIR}/../libgomp/.libs -lgomp"
Index: libstdc++-v3/testsuite/lib/libstdc++.exp
===================================================================
--- libstdc++-v3/testsuite/lib/libstdc++.exp	(revision 147493)
+++ libstdc++-v3/testsuite/lib/libstdc++.exp	(working copy)
@@ -239,6 +239,11 @@ proc libstdc++_init { testfile } {
     append cxxflags [getenv CXXFLAGS]
     v3track cxxflags 2

+    # If the compiler supports LTO, use it.
+    if [check_effective_target_lto] {
+      append cxxflags " -fwhopr"
+    }
+
     # Always use MO files built by this test harness.
     set cxxflags "$cxxflags -DLOCALEDIR=\".\""
     set ccflags "$cxxflags -DLOCALEDIR=\".\""


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