* [PATCH] Disable shrink-wrapping for ix86_static_chain_on_stack functions (PR target/67770)
@ 2015-11-18 23:18 Jakub Jelinek
2015-11-19 0:24 ` Bernd Schmidt
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2015-11-18 23:18 UTC (permalink / raw)
To: Uros Bizjak; +Cc: gcc-patches
Hi!
As the testcase shows, shrink-wrapping is incompatible with
ix86_static_chain_on_stack, where we rely on the very first instruction
in the (nested) function to be pushl %esi and use alternate entry
point right after that pushl instruction (one byte after the start of
the nested function). If shrink-wrapping moves the prologue somewhere else,
then this is no longer true.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk/5.3?
2015-11-18 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.
--- gcc/config/i386/i386.md.jj 2015-11-14 19:36:03.000000000 +0100
+++ gcc/config/i386/i386.md 2015-11-18 17:49:51.648115096 +0100
@@ -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)
{
--- gcc/testsuite/gcc.target/i386/pr67770.c.jj 2015-11-18 17:38:13.940956205 +0100
+++ gcc/testsuite/gcc.target/i386/pr67770.c 2015-11-18 17:53:22.354143509 +0100
@@ -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;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Disable shrink-wrapping for ix86_static_chain_on_stack functions (PR target/67770)
2015-11-18 23:18 [PATCH] Disable shrink-wrapping for ix86_static_chain_on_stack functions (PR target/67770) Jakub Jelinek
@ 2015-11-19 0:24 ` Bernd Schmidt
0 siblings, 0 replies; 2+ messages in thread
From: Bernd Schmidt @ 2015-11-19 0:24 UTC (permalink / raw)
To: Jakub Jelinek, Uros Bizjak; +Cc: gcc-patches
On 11/19/2015 12:18 AM, Jakub Jelinek wrote:
> As the testcase shows, shrink-wrapping is incompatible with
> ix86_static_chain_on_stack, where we rely on the very first instruction
> in the (nested) function to be pushl %esi and use alternate entry
> point right after that pushl instruction (one byte after the start of
> the nested function). If shrink-wrapping moves the prologue somewhere else,
> then this is no longer true.
>
> 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.
Looks reasonable. Ok.
Bernd
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-19 0:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-18 23:18 [PATCH] Disable shrink-wrapping for ix86_static_chain_on_stack functions (PR target/67770) Jakub Jelinek
2015-11-19 0:24 ` Bernd Schmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).