[ThinLTO] Loosen up variable importing correctness checks
authorTeresa Johnson <tejohnson@google.com>
Tue, 2 May 2023 02:04:00 +0000 (19:04 -0700)
committerTeresa Johnson <tejohnson@google.com>
Tue, 2 May 2023 14:49:03 +0000 (07:49 -0700)
commit48f18ecd8293e7828bf7ae2eeac975785892a0c4
tree7be408cd67be495844d52c6b5606cde83da06bd1
parent46740dd02babfc47edd9f8fdb03479ad61223246
[ThinLTO] Loosen up variable importing correctness checks

After importing variables, we do some checking to ensure that variables
marked read or write only, which have been marked exported (e.g.
because a referencing function has been exported), are on at least one
module's imports list. This is because the read or write only variables
will be internalized, so we need a copy any any module that references
it.

This checking is overly conservative in the case of linkonce_odr or
other linkage types where there can already be a duplicate copy in
existence in the importing module, which therefore wouldn't need to
import it. Loosen up the checking for these linkage types.

Fixes https://github.com/llvm/llvm-project/issues/62468.

Differential Revision: https://reviews.llvm.org/D149630
llvm/lib/Transforms/IPO/FunctionImport.cpp
llvm/test/ThinLTO/X86/check_var_import_odr.ll [new file with mode: 0644]