rust/src/test
bors c71248b708 Auto merge of #76859 - Aaron1011:fix/llvm-cgu-reuse, r=davidtwco,nikic
Use llvm::computeLTOCacheKey to determine post-ThinLTO CGU reuse

During incremental ThinLTO compilation, we attempt to re-use the
optimized (post-ThinLTO) bitcode file for a module if it is 'safe' to do
so.

Up until now, 'safe' has meant that the set of modules that our current
modules imports from/exports to is unchanged from the previous
compilation session. See PR #67020 and PR #71131 for more details.

However, this turns out be insufficient to guarantee that it's safe
to reuse the post-LTO module (i.e. that optimizing the pre-LTO module
would produce the same result). When LLVM optimizes a module during
ThinLTO, it may look at other information from the 'module index', such
as whether a (non-imported!) global variable is used. If this
information changes between compilation runs, we may end up re-using an
optimized module that (for example) had dead-code elimination run on a
function that is now used by another module.

Fortunately, LLVM implements its own ThinLTO module cache, which is used
when ThinLTO is performed by a linker plugin (e.g. when clang is used to
compile a C proect). Using this cache directly would require extensive
refactoring of our code - but fortunately for us, LLVM provides a
function that does exactly what we need.

The function `llvm::computeLTOCacheKey` is used to compute a SHA-1 hash
from all data that might influence the result of ThinLTO on a module.
In addition to the module imports/exports that we manually track, it
also hashes information about global variables (e.g. their liveness)
which might be used during optimization. By using this function, we
shouldn't have to worry about new LLVM passes breaking our module re-use
behavior.

In LLVM, the output of this function forms part of the filename used to
store the post-ThinLTO module. To keep our current filename structure
intact, this PR just writes out the mapping 'CGU name -> Hash' to a
file. To determine if a post-LTO module should be reused, we compare
hashes from the previous session.

This should unblock PR #75199 - by sheer chance, it seems to have hit
this issue due to the particular CGU partitioning and optimization
decisions that end up getting made.
2020-10-11 20:50:02 +00:00
..
assembly Add asm! support for mips64 2020-10-04 12:01:21 +00:00
auxiliary
codegen Revert "Assume slice len is bounded by allocation size" 2020-10-10 00:56:45 +03:00
codegen-units Move from {{closure}}#0 syntax to {closure#0} for (def) path components 2020-09-25 22:46:14 +01:00
compile-fail Add compile fail test for issue 27675 2020-10-08 08:18:59 +02:00
debuginfo debuginfo: Ignore HashMap tests before cdb 10.0.18362.1 2020-09-05 14:47:16 -07:00
incremental Auto merge of #76859 - Aaron1011:fix/llvm-cgu-reuse, r=davidtwco,nikic 2020-10-11 20:50:02 +00:00
mir-opt Fix tests from rebase 2020-10-06 11:19:33 +01:00
pretty pretty: trim paths of unique symbols 2020-09-02 22:26:37 +03:00
run-make cleaning up code 2020-09-25 15:13:55 +02:00
run-make-fulldeps Renamed tests to avoid exceeding Windows max path limit 2020-10-05 09:40:25 -07:00
run-pass-valgrind
rustdoc Re-enable test case 2020-10-10 15:56:51 +02:00
rustdoc-js Allow #[doc(alias)] on impl const items 2020-08-12 11:09:24 +02:00
rustdoc-js-std
rustdoc-ui Apply suggestions from code review 2020-10-10 15:52:57 +02:00
rustfix
ui Auto merge of #77774 - petrochenkov:floatuple, r=estebank 2020-10-11 03:54:26 +00:00
ui-fulldeps Replace run_compiler with RunCompiler builder pattern. 2020-10-08 16:11:45 -03:00
COMPILER_TESTS.md