public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH TESTSUITE]: Fix ipa-cp-1 when -fpic by creating new dg-add-options  "bind-pic-locally"
@ 2009-10-15 15:44 Kaveh R. GHAZI
  2009-10-15 17:29 ` Janis Johnson
  0 siblings, 1 reply; 4+ messages in thread
From: Kaveh R. GHAZI @ 2009-10-15 15:44 UTC (permalink / raw)
  To: gcc-patches; +Cc: janis187

There's another new test that fails with -fpic/-fPIC, which is cured by
binding functions locally using -fpie.  The current scheme for adding
-fpie is to do something like this:

 /* { dg-options "-O3 -fdump-tree-optimized -fno-inline" } */
+/* { dg-options "-O3 -fdump-tree-optimized -fno-inline -fpie" { target { ! nonpic } } } */

I.e. you copy the dg-options line, add -fpie, and put in a pic target
check.  I'm not a fan of this because it's ugly, it's fragile and it
forces future developers to add new flags in two places should the rare
need arise to change the testcase.

So I decided to try writing a dg-add-options procedure instead.  In
addition to being more elegant, another advantage here is that it can do
-fpie or -fPIE depending on which kind of pic/PIC code you are using.  It
hasn't seemed to matter on x86; but what the heck, other platforms might
care...  Anyway I'm not sure if this patch is right, I just copied and
pasted code from the ieee add-options procedure until it worked. :-P
If this is approved, I'll create followup patches to convert the other
tests needing -fpie to use this instead.

Tested on x86_64-unknown-linux-gnu with -fpic/-fPIC/regular passes.  No
regressions and the ipa-cp-1.c test is fixed.  I also inspected the
gcc.log file and visually verified that the ipa-cp-1.c test gets the right
flags for each pass.

Okay for mainline?

		Thanks,
		--Kaveh


2009-10-15  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* lib/target-supports.exp (add_options_for_bind_pic_locally): New.
	* gcc.dg/tree-ssa/ipa-cp-1.c: Bind pic locally.

diff -rup orig/egcc-SVN20091014/gcc/testsuite/lib/target-supports.exp egcc-SVN20091014/gcc/testsuite/lib/target-supports.exp
--- orig/egcc-SVN20091014/gcc/testsuite/lib/target-supports.exp	2009-10-14 03:24:05.000000000 +0200
+++ egcc-SVN20091014/gcc/testsuite/lib/target-supports.exp	2009-10-15 04:01:10.000000000 +0200
@@ -2984,6 +2984,28 @@ proc add_options_for_ieee { flags } {
     return $flags
 }

+# Add to FLAGS the flags needed to enable functions to bind locally
+# when using pic/PIC passes in the testsuite.
+
+proc add_options_for_bind_pic_locally { flags } {
+    if {[check_no_compiler_messages using_pic2 assembly {
+        #if __PIC__ != 2
+        #error FOO
+        #endif
+    }]} {
+	return "$flags -fPIE"
+    }
+    if {[check_no_compiler_messages using_pic1 assembly {
+        #if __PIC__ != 1
+        #error FOO
+        #endif
+    }]} {
+	return "$flags -fpie"
+    }
+
+    return $flags
+}
+
 # Return 1 if the target provides a full C99 runtime.

 proc check_effective_target_c99_runtime { } {
diff -rup orig/egcc-SVN20091014/gcc/testsuite/gcc.dg/tree-ssa/ipa-cp-1.c egcc-SVN20091014/gcc/testsuite/gcc.dg/tree-ssa/ipa-cp-1.c
--- orig/egcc-SVN20091014/gcc/testsuite/gcc.dg/tree-ssa/ipa-cp-1.c	2009-10-04 02:00:21.000000000 +0200
+++ egcc-SVN20091014/gcc/testsuite/gcc.dg/tree-ssa/ipa-cp-1.c	2009-10-15 03:53:19.000000000 +0200
@@ -1,5 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O3 -fdump-tree-optimized -fno-inline" } */
+/* { dg-add-options bind_pic_locally } */
+
 int
 very_long_function(int a)
 {

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-10-16 16:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-15 15:44 [PATCH TESTSUITE]: Fix ipa-cp-1 when -fpic by creating new dg-add-options "bind-pic-locally" Kaveh R. GHAZI
2009-10-15 17:29 ` Janis Johnson
2009-10-16 15:55   ` Kaveh R. GHAZI
2009-10-16 16:52     ` Janis Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).