public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: David Edelsohn <dje.gcc@gmail.com>,
	Segher Boessenkool <segher@kernel.crashing.org>
Subject: [RS6000] Fragile testcase breaks with -frename-registers
Date: Tue, 03 May 2016 14:35:00 -0000	[thread overview]
Message-ID: <20160503143545.GN18915@bubble.grove.modra.org> (raw)

See comments added below.  Bootstrapped and regression tested
powerpc64le-linux.  OK to apply?

	PR testsuite/70826
	* gcc.target/powerpc/savres.c: Compile with -fno-rename-registers.

diff --git a/gcc/testsuite/gcc.target/powerpc/savres.c b/gcc/testsuite/gcc.target/powerpc/savres.c
index f10c99a..9c4c627 100644
--- a/gcc/testsuite/gcc.target/powerpc/savres.c
+++ b/gcc/testsuite/gcc.target/powerpc/savres.c
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-fno-inline -fomit-frame-pointer" } */
+/* { dg-options "-fno-inline -fomit-frame-pointer -fno-rename-registers" } */
 /* { dg-additional-options "-mdynamic-no-pic" { target *-*-darwin* } } */
 
 /* -fno-inline -maltivec -m32/-m64 -mmultiple/no-multiple -Os/-O2.  */
@@ -10,6 +10,13 @@
 #define SET_GPR(R,V) SET (long, R, V)
 #define SET_FPR(R,V) SET (double, R, V)
 #define SET_VR(R,V) SET (__attribute__ ((vector_size (16))) int, R, V)
+/* There doesn't seem to be a way of letting gcc know that cr2, cr3
+   and cr4 are being used, and therefore should not be touched by
+   gcc.  Unlike gpr, fpr and vr we can't do something like
+   register __attribute__ ((__mode__ ("__CC__"))) int cr2 __asm__ ("cr2");
+   This makes the test somewhat fragile, dependent on gcc not using
+   any of cr2, cr3 and cr4 in main(), and is why -fno-rename-registers
+   is required.  */
 #define SET_CR(R,V) __asm__ __volatile__ ("mtcrf %0,%1" : : "n" (1<<(7-R)), "r" (V<<(4*(7-R))) : "cr" #R)
 #define TRASH_GPR(R) SET_GPR (R, 0)
 #define TRASH_FPR(R) SET_FPR (R, 0)
@@ -1053,7 +1060,18 @@ void ws_0 (void)
     abort ();
 }
 
-int main (void)
+/* We'd like to compile main with
+   __attribute__ ((__optimize__ ("fixed-cr2,fixed-cr3,fixed-cr4")))
+   but that doesn't do anything currently.  Obviously we don't want to
+   compile the whole file with -ffixed-cr2 -ffixed-cr3 -ffixed-cr4 as
+   that would also tell gcc not to save/restore cr, and we're trying
+   to check that the above functions do save/restore cr.
+   __attribute__ ((__optimize__ ("no-rename-registers,omit-frame-pointer")))
+   works, but it seems odd to need omit-frame-pointer and raises the
+   question of whether darwin would need -mdynamic-no-pic.
+   So for now use -fno-rename-registers over the whole test.  */
+int
+main (void)
 {
   INIT_REGS;
   USE_ALL_CR;

-- 
Alan Modra
Australia Development Lab, IBM

             reply	other threads:[~2016-05-03 14:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-03 14:35 Alan Modra [this message]
2016-05-09 12:25 ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160503143545.GN18915@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=segher@kernel.crashing.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).