aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Krebbel <krebbel@linux.ibm.com>2020-10-27 20:57:39 +0100
committerAndreas Krebbel <krebbel@linux.ibm.com>2020-10-27 21:01:26 +0100
commit2b3e722a3ca1b9dcfff1c016e651d0d681de1af0 (patch)
tree8d53373084046f89e9d9ad197f17d28198525265
parenta764c40079a493826a3678174f908941a383644e (diff)
downloadgcc-2b3e722a3ca1b9dcfff1c016e651d0d681de1af0.zip
gcc-2b3e722a3ca1b9dcfff1c016e651d0d681de1af0.tar.gz
gcc-2b3e722a3ca1b9dcfff1c016e651d0d681de1af0.tar.bz2
Fix PR97497
This works around a limitation of gcse with handling of partially clobbered registers. With this patch our GOT pointer register r12 is not marked as partially clobbered anymore for the -m31 -mzarch -fpic combination. This is correct since all the bits in r12 we actually care about are in fact preserved. gcc/ChangeLog: PR rtl-optimization/97497 * config/s390/s390.c (s390_hard_regno_call_part_clobbered): Do not return true for r12 when -fpic is used. gcc/testsuite/ChangeLog: * gcc.target/s390/pr97497.c: New test.
-rw-r--r--gcc/config/s390/s390.c7
-rw-r--r--gcc/testsuite/gcc.target/s390/pr97497.c36
2 files changed, 43 insertions, 0 deletions
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index f9b27f9..3c3feb2 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -10376,9 +10376,16 @@ static bool
s390_hard_regno_call_part_clobbered (unsigned int, unsigned int regno,
machine_mode mode)
{
+ /* For r12 we know that the only bits we actually care about are
+ preserved across function calls. Since r12 is a fixed reg all
+ accesses to r12 are generated by the backend.
+
+ This workaround is necessary until gcse implements proper
+ tracking of partially clobbered registers. */
if (!TARGET_64BIT
&& TARGET_ZARCH
&& GET_MODE_SIZE (mode) > 4
+ && (!flag_pic || regno != PIC_OFFSET_TABLE_REGNUM)
&& ((regno >= 6 && regno <= 15) || regno == 32))
return true;
diff --git a/gcc/testsuite/gcc.target/s390/pr97497.c b/gcc/testsuite/gcc.target/s390/pr97497.c
new file mode 100644
index 0000000..460c850
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr97497.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -march=z900 -mzarch -fpic" } */
+
+char *t;
+
+void __attribute__((noinline,noclone))
+bar(int a, char* b)
+{
+ if (a != 1)
+ __builtin_abort();
+}
+
+void __attribute__((noinline,noclone))
+baz(char* a, int b)
+{
+ if (b != 1)
+ __builtin_abort();
+}
+
+int __attribute__((noinline,noclone))
+foo (int a)
+{
+ bar (1, t);
+ if (a)
+ baz (t, 1);
+
+ bar (1, t);
+}
+
+int
+main ()
+{
+ foo (1);
+
+ return 0;
+}