The following patch is a partial reversal of r250815 (on the branch)
which restores behavior of always calling find_many_sub_basic_blocks
on prologue inserted code.  Doing that probably masks an issue with
either scheduling or the way x86 sets up the PIC register.

The patch allows grub2 to successfully test the availability of
-mcmodel=large.

Bootstrap / regtest running on x86_64-unknown-linux-gnu, ok for
the branch?

I'd appreciate more analysis for a trunk fix from someone who knows RTL
constraints better than me.  This patch looks better than full reversal
of the patch.

I'll do RC2 when this is on the branch, the 7.2 release will be delayed
until next week (I'm on PTO this week apart from today).

Thanks,
Richard.

2017-08-08  Richard Biener  <rguent...@suse.de>

        PR middle-end/81766
        * function.c (thread_prologue_and_epilogue_insns): Restore
        behavior of always calling find_many_sub_basic_blocks on
        the inserted prologue.

        * gcc.target/i386/pr81766.c: New testcase.

Index: gcc/function.c
===================================================================
--- gcc/function.c      (revision 250947)
+++ gcc/function.c      (working copy)
@@ -6082,17 +6082,16 @@ thread_prologue_and_epilogue_insns (void
       if (prologue_insn
          && BLOCK_FOR_INSN (prologue_insn) == NULL)
        prologue_insn = NULL;
-      if (split_prologue_insn || prologue_insn)
-       {
-         auto_sbitmap blocks (last_basic_block_for_fn (cfun));
-         bitmap_clear (blocks);
-         if (split_prologue_insn)
-           bitmap_set_bit (blocks,
-                           BLOCK_FOR_INSN (split_prologue_insn)->index);
-         if (prologue_insn)
-           bitmap_set_bit (blocks, BLOCK_FOR_INSN (prologue_insn)->index);
-         find_many_sub_basic_blocks (blocks);
-       }
+      auto_sbitmap blocks (last_basic_block_for_fn (cfun));
+      bitmap_clear (blocks);
+      if (split_prologue_insn)
+       bitmap_set_bit (blocks,
+                       BLOCK_FOR_INSN (split_prologue_insn)->index);
+      if (prologue_insn)
+       bitmap_set_bit (blocks, BLOCK_FOR_INSN (prologue_insn)->index);
+      bitmap_set_bit (blocks, entry_edge->dest->index);
+      bitmap_set_bit (blocks, orig_entry_edge->dest->index);
+      find_many_sub_basic_blocks (blocks);
     }
 
   default_rtl_profile ();
Index: gcc/testsuite/gcc.target/i386/pr81766.c
===================================================================
--- gcc/testsuite/gcc.target/i386/pr81766.c     (nonexistent)
+++ gcc/testsuite/gcc.target/i386/pr81766.c     (working copy)
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O2 -fPIE -mcmodel=large" } */
+
+int main() { return 0; }

Reply via email to