[PATCH] D54635: [ThinLTO] Consolidate cache key computation between new/old LTO APIs

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 16 10:00:41 PST 2018


tejohnson created this revision.
tejohnson added reviewers: steven_wu, pcc.
Herald added subscribers: dang, dexonsmith, eraman, inglorion, mehdi_amini.

The old legacy LTO API had a separate cache key computation, which was
a subset of the cache key computation in the new LTO API (from what I
can tell this is largely just because certain features such as CFI,
dsoLocal, etc are only utilized via the new LTO API). However, having
separate computations is unnecessary (much of the code is duplicated),
and can lead to bugs when adding new optimizations if both cache
computation algorithms aren't updated properly - it's much easier to
maintain if we have a single facility.

This patch refactors the old LTO API code to use the cache key
computation from the new LTO API. To do this, we set up an lto::Config
object and fill in the fields that the old LTO was hashing (the others
will just use the defaults).

There are two notable changes:

- I added a Freestanding flag to the LTO Config. Currently this is only

used by the legacy LTO API. In the patch that added it (https://reviews.llvm.org/D30791) I had
asked about adding it to the new LTO API, but it looks like that was not
addressed. This should probably be discussed as a follow up to this
change, as it is orthogonal.

- The legacy LTO API had some code that was hashing the GUID of all

preserved symbols defined in the module. I looked back at the history of
this (which was added with the original hashing in the legacy LTO API in
https://reviews.llvm.org/D18494), and there is a comment in the review thread that it was added
in preparation for future internalization. We now do the internalization
of course, and that is handled in the new LTO API cache key computation
by hashing the recorded linkage type of all defined globals. Therefore I
didn't try to move over and keep the preserved symbols handling.


Repository:
  rL LLVM

https://reviews.llvm.org/D54635

Files:
  include/llvm/LTO/Config.h
  include/llvm/LTO/LTO.h
  lib/LTO/LTO.cpp
  lib/LTO/ThinLTOCodeGenerator.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54635.174392.patch
Type: text/x-patch
Size: 8921 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181116/6b90b951/attachment.bin>


More information about the llvm-commits mailing list