public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/94145] New: Longcalls mis-optimize loading the function address
@ 2020-03-11 16:00 meissner at gcc dot gnu.org
  2020-03-11 18:27 ` [Bug target/94145] " meissner at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: meissner at gcc dot gnu.org @ 2020-03-11 16:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94145

            Bug ID: 94145
           Summary: Longcalls mis-optimize loading the function address
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: meissner at gcc dot gnu.org
  Target Milestone: ---

I'm working on a feature where we convert some/all built-in function calls to
use the longcall sequence.  I discovered that the compiler is mis-optimizing
loading up the function address.  This showed up in the Spec 2017 wrf_r
benchmark where I replaced some 60,000 direct calls to longcalls.

In particular, the PowerPC backend is not marking the load of the function
address as being volatile.  This allows the compiler to move the load out of a
loop.

However with the current ELF semantics, you don't want to do this because the
function address changes.  The first call to the function, the address is the
PLT stub, but in subsequent calls it is the address of the function itself
after the shared library is loaded.

In addition, because UNSPECs are used, the compiler is likely to store the
function address in the stack and reload it.  Given that the UNSPEC is just a
load, it would be better not to optimize this to doing the extra load/store.

In fixing the linker bug that this feature uncovered, Alan Modra has a simple
patch to fix it.

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

end of thread, other threads:[~2020-05-01  1:19 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-11 16:00 [Bug target/94145] New: Longcalls mis-optimize loading the function address meissner at gcc dot gnu.org
2020-03-11 18:27 ` [Bug target/94145] " meissner at gcc dot gnu.org
2020-03-11 21:33 ` segher at gcc dot gnu.org
2020-03-11 21:35 ` segher at gcc dot gnu.org
2020-03-11 22:50 ` amodra at gmail dot com
2020-03-11 22:50 ` amodra at gmail dot com
2020-03-12  8:48 ` rguenth at gcc dot gnu.org
2020-03-12 13:00 ` amodra at gmail dot com
2020-03-12 13:17 ` rguenth at gcc dot gnu.org
2020-03-12 13:34 ` amodra at gmail dot com
2020-03-12 13:57 ` rguenth at gcc dot gnu.org
2020-03-12 15:38 ` segher at gcc dot gnu.org
2020-03-27 22:16 ` cvs-commit at gcc dot gnu.org
2020-05-01  1:18 ` cvs-commit at gcc dot gnu.org
2020-05-01  1:19 ` amodra at gmail dot com

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