re PR target/91472 (gmp testsuite segfaults with gcc-8 and gcc-9, works fine with...
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 1 Sep 2019 12:55:22 +0000 (12:55 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sun, 1 Sep 2019 12:55:22 +0000 (12:55 +0000)
PR target/91472
* config/sparc/sparc.c (sparc_cannot_force_const_mem): Return true
during LRA/reload in PIC mode if the PIC register hasn't been used yet.
(sparc_pic_register_p): Test reload_in_progress for consistency's sake.

From-SVN: r275270

gcc/ChangeLog
gcc/config/sparc/sparc.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20190901-1.c [new file with mode: 0644]

index 6c43782b358fbe8b4d105ac88a9ab1e597ae2ad8..f17b4d563382e10f0bada7c1f85bb6dae0c38744 100644 (file)
@@ -1,3 +1,10 @@
+2019-09-01  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR target/91472
+       * config/sparc/sparc.c (sparc_cannot_force_const_mem): Return true
+       during LRA/reload in PIC mode if the PIC register hasn't been used yet.
+       (sparc_pic_register_p): Test reload_in_progress for consistency's sake.
+
 2019-09-01  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/91623
index 68e3dce3bb215c1edda28b6398d1577e4ef7b1db..634a3343eb0905d03b391b4d0d029ad99aeab5d2 100644 (file)
@@ -4201,6 +4201,13 @@ eligible_for_sibcall_delay (rtx_insn *trial)
 static bool
 sparc_cannot_force_const_mem (machine_mode mode, rtx x)
 {
+  /* After IRA has run in PIC mode, it is too late to put anything into the
+     constant pool if the PIC register hasn't already been initialized.  */
+  if ((lra_in_progress || reload_in_progress)
+      && flag_pic
+      && !crtl->uses_pic_offset_table)
+    return true;
+
   switch (GET_CODE (x))
     {
     case CONST_INT:
@@ -4450,7 +4457,7 @@ sparc_pic_register_p (rtx x)
     return true;
 
   if (!HARD_REGISTER_P (pic_offset_table_rtx)
-      && (HARD_REGISTER_P (x) || lra_in_progress)
+      && (HARD_REGISTER_P (x) || lra_in_progress || reload_in_progress)
       && ORIGINAL_REGNO (x) == REGNO (pic_offset_table_rtx))
     return true;
 
index 308e4735c1c5eca68ffab1485d478541357283a1..72c0abb5d3d6131dbfa0ac2ac6186f3b91bc5868 100644 (file)
@@ -1,3 +1,7 @@
+2019-09-01  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.c-torture/execute/20190901-1.c: New test.
+
 2019-09-01  Paul Thomas  <pault@gcc.gnu.org>
 
        * gfortran.dg/select_rank_1.f90 : New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20190901-1.c b/gcc/testsuite/gcc.c-torture/execute/20190901-1.c
new file mode 100644 (file)
index 0000000..c78715e
--- /dev/null
@@ -0,0 +1,36 @@
+/* PR target/91472 */
+/* Reported by John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> */
+
+typedef unsigned int gmp_uint_least32_t;
+
+union ieee_double_extract
+{
+  struct
+    {
+      gmp_uint_least32_t sig:1;
+      gmp_uint_least32_t exp:11;
+      gmp_uint_least32_t manh:20;
+      gmp_uint_least32_t manl:32;
+    } s;
+  double d;
+};
+
+double __attribute__((noipa))
+tests_infinity_d (void)
+{
+  union ieee_double_extract x;
+  x.s.exp = 2047;
+  x.s.manl = 0;
+  x.s.manh = 0;
+  x.s.sig = 0;
+  return x.d;
+}
+
+int
+main (void)
+{
+  double x = tests_infinity_d ();
+  if (x == 0.0)
+    __builtin_abort ();
+  return 0;
+}