From 377e1311d50c7e5b5aab3db081938e0d0ceebdfc Mon Sep 17 00:00:00 2001 From: Shoaib Meenai Date: Fri, 24 Mar 2023 17:34:14 -0700 Subject: [ThinLTO] Only import for non-prevailing interposable global variables This logic was added in https://reviews.llvm.org/D95943 specifically to handle an issue for non-prevailing global variables. It turns out that it adds a new issue for prevailing glboal variables, since those could be replaced by an available_externally definition and hence incorrectly omitted from the output object file. Limit the import to non-prevailing global variables to fix this, as suggested by @tejohnson. The bulk of the diff is mechanical changes to thread isPrevailing through to where it's needed and ensure it's available before the relevant calls; the actual logic change itself is straightforward. Fixes https://github.com/llvm/llvm-project/issues/61677 Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D146876 --- llvm/lib/LTO/LTO.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/LTO/LTO.cpp') diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index ee6b8c3..4d6a620 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -1553,7 +1553,7 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache, if (Conf.OptLevel > 0) ComputeCrossModuleImport(ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries, - ImportLists, ExportLists); + isPrevailing, ImportLists, ExportLists); // Figure out which symbols need to be internalized. This also needs to happen // at -O0 because summary-based DCE is implemented using internalization, and -- cgit v1.1