public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* LTO Optimization with asm renames of intrinsic functions
@ 2020-08-12 22:26 Paul E Murphy
  2020-08-13  3:17 ` Jeff Law
  2020-08-13 23:07 ` Segher Boessenkool
  0 siblings, 2 replies; 4+ messages in thread
From: Paul E Murphy @ 2020-08-12 22:26 UTC (permalink / raw)
  To: gcc-help

I ran into a slight divergence of behavior when enabling LTO using GCC
10.2 or newer when building libdfp on x86 and ppc64.

Libdfp builds a copy of libdecnumber which exports its own copy of ABI
as specified for _Decimal types in the GCC documentation.  Some of this
ABI is implicitly used in libdfp to implement various facilities.

These intrinsic calls generate PLT calls which should resolve to
symbols provided by libdfp.  However, libdfp tries to avoid these
by inserting asm renames of the form:

   asm ("__bid_floatsidd  = __GI___bid_floatsidd");

Where the libdfp copy of such symbols are prefixed with __GI_ using
the trick inherited from glibc.

This creative workaround has worked with lto disabled, but
when enabled, it is effectively ignored.  Is there a more robust way
to bypass plt calls for intrinsic functions when using LTO?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: LTO Optimization with asm renames of intrinsic functions
  2020-08-12 22:26 LTO Optimization with asm renames of intrinsic functions Paul E Murphy
@ 2020-08-13  3:17 ` Jeff Law
  2020-08-13 23:07 ` Segher Boessenkool
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff Law @ 2020-08-13  3:17 UTC (permalink / raw)
  To: Paul E Murphy, gcc-help

On Wed, 2020-08-12 at 17:26 -0500, Paul E Murphy via Gcc-help wrote:
> I ran into a slight divergence of behavior when enabling LTO using GCC
> 10.2 or newer when building libdfp on x86 and ppc64.
> 
> Libdfp builds a copy of libdecnumber which exports its own copy of ABI
> as specified for _Decimal types in the GCC documentation.  Some of this
> ABI is implicitly used in libdfp to implement various facilities.
> 
> These intrinsic calls generate PLT calls which should resolve to
> symbols provided by libdfp.  However, libdfp tries to avoid these
> by inserting asm renames of the form:
> 
>    asm ("__bid_floatsidd  = __GI___bid_floatsidd");
If you've got an ASM like this, then you can't use LTO.  In simplest terms LTO
doesn't look inside ASMs for symbol references and can't inherently do the right
thing.

You might be able to use the symver attribute to do renaming, but I don't know if
anyone's tried it yet for anything other than specifying symbol versioning.

jeff
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: LTO Optimization with asm renames of intrinsic functions
  2020-08-12 22:26 LTO Optimization with asm renames of intrinsic functions Paul E Murphy
  2020-08-13  3:17 ` Jeff Law
@ 2020-08-13 23:07 ` Segher Boessenkool
  2020-08-14  4:24   ` Jeff Law
  1 sibling, 1 reply; 4+ messages in thread
From: Segher Boessenkool @ 2020-08-13 23:07 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: gcc-help

On Wed, Aug 12, 2020 at 05:26:35PM -0500, Paul E Murphy via Gcc-help wrote:
>   asm ("__bid_floatsidd  = __GI___bid_floatsidd");

> This creative workaround has worked with lto disabled, but
> when enabled, it is effectively ignored.  Is there a more robust way
> to bypass plt calls for intrinsic functions when using LTO?

Do linker scripts work with LTO?  You can do this in a linker script
(which is neater than doing it in assembler, anyway :-) )


Segher

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: LTO Optimization with asm renames of intrinsic functions
  2020-08-13 23:07 ` Segher Boessenkool
@ 2020-08-14  4:24   ` Jeff Law
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2020-08-14  4:24 UTC (permalink / raw)
  To: Segher Boessenkool, Paul E Murphy; +Cc: gcc-help

On Thu, 2020-08-13 at 18:07 -0500, Segher Boessenkool wrote:
> On Wed, Aug 12, 2020 at 05:26:35PM -0500, Paul E Murphy via Gcc-help wrote:
> >   asm ("__bid_floatsidd  = __GI___bid_floatsidd");
> > This creative workaround has worked with lto disabled, but
> > when enabled, it is effectively ignored.  Is there a more robust way
> > to bypass plt calls for intrinsic functions when using LTO?
> 
> Do linker scripts work with LTO?  You can do this in a linker script
> (which is neater than doing it in assembler, anyway :-) )
I wouldn't think that anything with symbol manipulation would work since LTO
wouldn't know about anything the linker script did.


jeff


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-14  4:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-12 22:26 LTO Optimization with asm renames of intrinsic functions Paul E Murphy
2020-08-13  3:17 ` Jeff Law
2020-08-13 23:07 ` Segher Boessenkool
2020-08-14  4:24   ` Jeff Law

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).