@@ -12187,10 +12187,14 @@ (define_expand "return"
;; 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)
{
@@ -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;
+}