This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH i386] Allow sibcalls in no-PLT PIC
- From: Richard Henderson <rth at redhat dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Rich Felker <dalias at libc dot org>, Michael Matz <matz at suse dot de>, Jan Hubicka <hubicka at ucw dot cz>, Alexander Monakov <amonakov at ispras dot ru>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Uros Bizjak <ubizjak at gmail dot com>
- Date: Tue, 19 May 2015 12:47:57 -0700
- Subject: Re: [PATCH i386] Allow sibcalls in no-PLT PIC
- Authentication-results: sourceware.org; auth=none
- References: <20150515194824 dot GB14415 at kam dot mff dot cuni dot cz> <CAMe9rOr3yQv-+cJxwp_YfNY=9G+FnV6=JdYh_T6kPDJtSA0fzg at mail dot gmail dot com> <20150515202319 dot GE17573 at brightrain dot aerifal dot cx> <CAMe9rOqRBz7L6Fr1nxDVrTEh3EQ-AVV0dMCC0-xdpq87k=e4EQ at mail dot gmail dot com> <20150515204237 dot GF17573 at brightrain dot aerifal dot cx> <CAMe9rOp1ibVzf0KOt+1boOxb5ag85fe2Rv2Rst=CgAtOTGFBxA at mail dot gmail dot com> <20150515230810 dot GA73210 at kam dot mff dot cuni dot cz> <CAMe9rOr1_r0tvi_JdsCL8w-MMAqhSeVpA6sbksnn1yP224zn_A at mail dot gmail dot com> <20150515234403 dot GG17573 at brightrain dot aerifal dot cx> <alpine dot LSU dot 2 dot 20 dot 1505191637140 dot 27315 at wotan dot suse dot de> <20150519180659 dot GG17573 at brightrain dot aerifal dot cx> <555B87F4 dot 30908 at redhat dot com> <CAMe9rOpPa9edYxaHQ1BOSfq4VuLsEQZHB=hXxdagTXpqv2qc=A at mail dot gmail dot com> <555B8ACD dot 20503 at redhat dot com> <CAMe9rOq4-F7+LCxee82LzFS9WjvfErZCDoS=TraXPsakRnyJRQ at mail dot gmail dot com>
On 05/19/2015 12:17 PM, H.J. Lu wrote:
>> But my point is that the only time the compiler should present you with the
>> form of indirect branch you're looking for is when there's no place to hoist
>> the load.
>>
>> At which point, is it really worth adding a new relocation to the ABI? Is it
>> really worth adding new code to the linker that won't be exercised often?
>
> I believe there are plenty of indirect branches via GOT when compiling
> PIE/PIC with -fno-plt:
>
> [hjl@gnu-6 gcc]$ cat /tmp/x.c
> extern void foo (void);
>
> void
> bar (void)
> {
> foo ();
> }
Sure, as I said, when there's no place to hoist the load.
Try anything more complicated,
void bar (void)
{
int i;
for (i = 0; i < 10; ++i)
foo ();
}
void baz (void)
{
foo ();
foo ();
}
and you'll not see the call *foo@GOTPCREL(%rip) form.
Of course there's also plenty of times where combine recreates exactly that
form when perhaps the scheduler might have preferred otherwise. Those are
optimization choices to be addressed under separate cover.
My point that we can already do what you want via LTO, without adding new
relocations, is still relevant.
r~