]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/67770 (i386: -fshrink-wrap can interact badly with trampolines)
authorJakub Jelinek <jakub@redhat.com>
Thu, 11 Feb 2016 09:04:19 +0000 (10:04 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 11 Feb 2016 09:04:19 +0000 (10:04 +0100)
Backported from mainline
2015-11-19  Jakub Jelinek  <jakub@redhat.com>

PR target/67770
* config/i386/i386.md (simple_return): Disable if
ix86_static_chain_on_stack is true.

* gcc.target/i386/pr67770.c: New test.

From-SVN: r233319

gcc/ChangeLog
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr67770.c [new file with mode: 0644]

index f5e18855d4733b25d76dbb1747aa7b8b20705bdc..f63667bcde57722417a6b8947ee3658ea51784df 100644 (file)
@@ -1,3 +1,12 @@
+2016-02-11  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2015-11-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/67770
+       * config/i386/i386.md (simple_return): Disable if
+       ix86_static_chain_on_stack is true.
+
 2016-02-04  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
index 2b19f6e307ecf0fbc2b410bd6457b02dd85569c7..bf148ed5cd2b0e37426feca78a5b6d415451c874 100644 (file)
 ;; We need to disable this for TARGET_SEH, as otherwise
 ;; shrink-wrapped prologue gets enabled too.  This might exceed
 ;; the maximum size of prologue in unwind information.
+;; Also disallow shrink-wrapping if using stack slot to pass the
+;; static chain pointer - the first instruction has to be pushl %esi
+;; and it can't be moved around, as we use alternate entry points
+;; in that case.
 
 (define_expand "simple_return"
   [(simple_return)]
-  "!TARGET_SEH"
+  "!TARGET_SEH && !ix86_static_chain_on_stack"
 {
   if (crtl->args.pops_args)
     {
index 0e077ca069d58dac69898d3aaaad22089361693d..48a77ec193157cb10b234080ae2cf4a054c80594 100644 (file)
@@ -1,3 +1,11 @@
+2016-02-11  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2015-11-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/67770
+       * gcc.target/i386/pr67770.c: New test.
+
 2016-02-04  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
diff --git a/gcc/testsuite/gcc.target/i386/pr67770.c b/gcc/testsuite/gcc.target/i386/pr67770.c
new file mode 100644 (file)
index 0000000..3826aff
--- /dev/null
@@ -0,0 +1,40 @@
+/* PR target/67770 */
+/* { dg-do run { target ia32 } } */
+/* { dg-require-effective-target trampolines } */
+/* { dg-options "-O2" } */
+
+#ifndef NO_TRAMPOLINES
+__attribute__ ((noinline)) void
+foo (int i, void (* __attribute__ ((regparm (3))) bar) (int))
+{
+  bar (i);
+}
+#endif
+
+int
+main ()
+{
+#ifndef NO_TRAMPOLINES
+  int p = 0;
+
+  __attribute__ ((regparm (3), noinline)) void
+  bar (int i)
+  {
+    if (__builtin_expect (i, 0))
+      ++p;
+  }
+
+  foo (0, bar);
+  bar (0);
+
+  if (p != 0)
+    __builtin_abort ();
+
+  foo (1, bar);
+  bar (1);
+
+  if (p != 2)
+    __builtin_abort ();
+#endif
+  return 0;
+}