[ThinLTO] Use module hash instead of module ID for cache key
authorNikita Popov <npopov@redhat.com>
Fri, 28 Jul 2023 12:21:00 +0000 (14:21 +0200)
committerTobias Hieta <tobias@hieta.se>
Sat, 29 Jul 2023 06:40:45 +0000 (08:40 +0200)
commitcff7a7747db02d1214b20e98677e5ddcb402ffe0
treeb66bdabded8c2f50322588e21ca8f427dfc0b369
parentbafedb1c2c64823ecee547f9776c4311a7f0930c
[ThinLTO] Use module hash instead of module ID for cache key

This is a followup to D151165. Instead of using the module ID, use
the module hash for sorting the import list. The module hash is what
will actually be included in the hash.

This has the advantage of being independent of the module order,
which is something that Rust relies on.

A caveat here is that the test doesn't quite work for linkonce_odr
functions, because the function may be imported from two different
modules, and the first one on the llvm-lto2 command line gets picked
(rather than, say, the prevailing copy). This doesn't really matter
for Rust's purposes (because it does not use linkonce_odr linkage),
but may still be worth addressing. For now I'm using a variant of
the test using internal instead of linkonce_odr functions.

Differential Revision: https://reviews.llvm.org/D156525

(cherry picked from commit 279c2971951c2ea58a2bd1e6687ce61451f9d329)
llvm/lib/LTO/LTO.cpp
llvm/test/ThinLTO/X86/Inputs/cache-import-lists3.ll [new file with mode: 0644]
llvm/test/ThinLTO/X86/Inputs/cache-import-lists4.ll [new file with mode: 0644]
llvm/test/ThinLTO/X86/cache-decoupled-from-order.ll [new file with mode: 0644]