[IPO] Opt-in local clones for thinlto imports
authorMircea Trofin <mtrofin@google.com>
Mon, 8 May 2023 22:31:27 +0000 (15:31 -0700)
committerMircea Trofin <mtrofin@google.com>
Thu, 11 May 2023 22:56:43 +0000 (15:56 -0700)
commit901183b5964c84d3ab6a3896b2c0ced7ffbd00f5
tree2789a506fd692c5e86ae7597591c49dec56e25ba
parent1030bd181eb74b67b7ea51631ce4becca410c406
[IPO] Opt-in local clones for thinlto imports

ThinLTO imports (which appear as `available_externally`) that survive
inlining get deleted. With today's inliner that's reasonable, because
the way the function would be inlined into in other modules would be the
same - because of the bottom-up traversal assumption, and the fact that
the inliner doesn't take into account surrounding context [*]. The
ModuleInliner invalidates the first assumption, and the ML inliner the
second.

This patch adds a way to opt-in a module to keep its variant of an
imported function, even if it survived past inlining.

[*] Almost. Deferred inlining is an exception which can lead to
(empirically) infrequent discrepancies.

Differential Revision: https://reviews.llvm.org/D150148
llvm/lib/Transforms/IPO/ElimAvailExtern.cpp
llvm/test/Transforms/EliminateAvailableExternally/transform-to-local.ll [new file with mode: 0644]