2014-01-15 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
authorkrebbel <krebbel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 15 Jan 2014 08:36:44 +0000 (08:36 +0000)
committerkrebbel <krebbel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 15 Jan 2014 08:36:44 +0000 (08:36 +0000)
* config/s390/s390.c (s390_preferred_reload_class): Don't return
ADDR_REGS for invalid symrefs in non-PIC code.

2014-01-15  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

* gcc.c-torture/compile/pr59803.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206623 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/s390/s390.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr59803.c [new file with mode: 0644]

index 5729efd..42c1344 100644 (file)
@@ -1,3 +1,8 @@
+2014-01-15  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
+
+       * config/s390/s390.c (s390_preferred_reload_class): Don't return
+       ADDR_REGS for invalid symrefs in non-PIC code.
+
 2014-01-15  Jakub Jelinek  <jakub@redhat.com>
 
        PR other/58712
index eeccaed..91f76f6 100644 (file)
@@ -3148,15 +3148,22 @@ s390_preferred_reload_class (rtx op, reg_class_t rclass)
         prefer ADDR_REGS.  If 'class' is not a superset
         of ADDR_REGS, e.g. FP_REGS, reject this reload.  */
       case CONST:
-       /* A larl operand with odd addend will get fixed via secondary
-          reload.  So don't request it to be pushed into literal
-          pool.  */
+       /* Symrefs cannot be pushed into the literal pool with -fPIC
+          so we *MUST NOT* return NO_REGS for these cases
+          (s390_cannot_force_const_mem will return true).  
+
+          On the other hand we MUST return NO_REGS for symrefs with
+          invalid addend which might have been pushed to the literal
+          pool (no -fPIC).  Usually we would expect them to be
+          handled via secondary reload but this does not happen if
+          they are used as literal pool slot replacement in reload
+          inheritance (see emit_input_reload_insns).  */
        if (TARGET_CPU_ZARCH
            && GET_CODE (XEXP (op, 0)) == PLUS
            && GET_CODE (XEXP (XEXP(op, 0), 0)) == SYMBOL_REF
            && GET_CODE (XEXP (XEXP(op, 0), 1)) == CONST_INT)
          {
-           if (reg_class_subset_p (ADDR_REGS, rclass))
+           if (flag_pic && reg_class_subset_p (ADDR_REGS, rclass))
              return ADDR_REGS;
            else
              return NO_REGS;
index c9eba44..7980dc3 100644 (file)
@@ -1,3 +1,7 @@
+2014-01-15  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
+
+       * gcc.c-torture/compile/pr59803.c: New testcase.
+
 2014-01-15  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/58943
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr59803.c b/gcc/testsuite/gcc.c-torture/compile/pr59803.c
new file mode 100644 (file)
index 0000000..d2b5d20
--- /dev/null
@@ -0,0 +1,27 @@
+/* PR target/59803 */
+
+extern void baz (void) __attribute__ ((__noreturn__));
+struct A { int g, h; };
+extern struct A a;
+struct B { unsigned char i, j, k, l, m; };
+int c, d, e;
+static int f;
+
+void
+foo (void)
+{
+  f = 1;
+}
+
+void
+bar (struct B *x)
+{
+  x->i = e;
+  x->k = c;
+  x->l = d;
+  x->j = a.h;
+  x->m = f;
+  if (x->i != e) baz ();
+  if (x->k != c) baz ();
+  if (x->j != a.h) baz ();
+}