This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR target/66232: -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT
- From: Alexander Monakov <amonakov at ispras dot ru>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Richard Henderson <rth at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Uros Bizjak <ubizjak at gmail dot com>
- Date: Mon, 25 May 2015 21:09:53 +0300 (MSK)
- Subject: Re: [PATCH] PR target/66232: -fPIC -fno-plt -mx32 fails to generate indirect branch via GOT
- Authentication-results: sourceware.org; auth=none
- References: <20150521125904 dot GA26391 at gmail dot com> <555E26F3 dot 3020202 at redhat dot com> <CAMe9rOr+hE_3W2AfXbZH0DziC-z6LA5xtx5OGNy40V5Df-9gRg at mail dot gmail dot com> <555E2CB8 dot 3040603 at redhat dot com> <CAMe9rOrD-VCAGSNs2D5h4+zn+LRmVO05cOjbj9By1-+Xy++BEQ at mail dot gmail dot com> <alpine dot LNX dot 2 dot 11 dot 1505212231270 dot 22867 at monopod dot intra dot ispras dot ru> <CAMe9rOpsytbFciE4nGwA40i6dgjjKPOLRYSSQcbggqc6jjCb4g at mail dot gmail dot com> <alpine dot LNX dot 2 dot 11 dot 1505212239550 dot 22867 at monopod dot intra dot ispras dot ru>
> On Thu, 21 May 2015, H.J. Lu wrote:
>
> > On Thu, May 21, 2015 at 12:32 PM, Alexander Monakov <amonakov@ispras.ru> wrote:
> > > On Thu, 21 May 2015, H.J. Lu wrote:
> > >> On Thu, May 21, 2015 at 12:06 PM, Richard Henderson <rth@redhat.com> wrote:
> > >> > On 05/21/2015 12:01 PM, H.J. Lu wrote:
> > >> >> +++ b/gcc/testsuite/gcc.target/i386/pr66232-1.c
> > >> >> @@ -0,0 +1,13 @@
> > >> >> +/* { dg-do compile { target *-*-linux* } } */
> > >> >> +/* { dg-options "-O2 -fpic -fno-plt" } */
> > >> >> +
> > >> >> +extern void bar (void);
> > >> >> +
> > >> >> +void
> > >> >> +foo (void)
> > >> >> +{
> > >> >> + bar ();
> > >> >> +}
> > >> >> +
> > >> >> +/* { dg-final { scan-assembler "jmp\[ \t\]*.bar@GOTPCREL" { target { ! ia32 } } } } */
> > >> >> +/* { dg-final { scan-assembler "call\[ \t\]*.bar@GOT\\(" { target ia32 } } } */
> > >> >
> > >> > Do you really want to check for no tail call for ia32 here?
> > >> > That's really just a missed optimization, surely.
> > >> >
> > >> >
> > >>
> > >> I'd like to keep it. When it is fixed, we can update it. I tried:
> > >>
> > >> https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00230.html
> > >>
> > >> and got
> > >>
> > >> call __x86.get_pc_thunk.ax
> > >> addl $_GLOBAL_OFFSET_TABLE_, %eax
> > >> subl $28, %esp
> > >> .cfi_def_cfa_offset 32
> > >> movl bar@GOT(%eax), %eax
> > >> movl %eax, 12(%esp)
> > >> addl $28, %esp
> > >> .cfi_def_cfa_offset 4
> > >> jmp *%eax
> > >>
> > >> This is very odd code, comparing against
> > >
> > > To avoid that, you need the CLOBBERED_REGS patch too:
> > > https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00227.html
> > >
> >
> > Should both patches be needed for ia32 tail call?
>
> I don't really understand the question. The first patch (that you've linked)
> is required to produce a tail call, the second patch (that I've linked) helps
> to produce clean code. To match the scan-assembler test as written in your
> testcase, both patches are needed.
I have pushed those patches and updated the scan patterns to match
memory-indirect jump rather than call.
Alexander