[all-commits] [llvm/llvm-project] e97aab: [ThinLTO] Fix import of multiply defined global va...

chbessonova via All-commits all-commits at lists.llvm.org
Sun Feb 21 08:43:42 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e97aab8d1510a484a19016cf079e1a8f913cf7cd
      https://github.com/llvm/llvm-project/commit/e97aab8d1510a484a19016cf079e1a8f913cf7cd
  Author: Kristina Bessonova <kbessonova at accesssoftek.com>
  Date:   2021-02-21 (Sun, 21 Feb 2021)

  Changed paths:
    M llvm/lib/Transforms/IPO/FunctionImport.cpp
    A llvm/test/ThinLTO/X86/weak_globals_import.ll

  Log Message:
  -----------
  [ThinLTO] Fix import of multiply defined global variables

Currently, if there is a module that contains a strong definition of
a global variable and a module that has both a weak definition for
the same global and a reference to it, it may result in an undefined symbol error
while linking with ThinLTO.

It happens because:
* the strong definition become internal because it is read-only and can be imported;
* the weak definition gets replaced by a declaration because it's non-prevailing;
* the strong definition failed to be imported because the destination module
  already contains another definition of the global yet this def is non-prevailing.

The patch adds a check to computeImportForReferencedGlobals() that allows
considering a global variable for being imported even if the module contains
a definition of it in the case this def has an interposable linkage type.

Note that currently the check is based only on the linkage type
(and this seems to be enough at the moment), but it might be worth to account
the information whether the def is prevailing or not.

Reviewed By: tejohnson

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




More information about the All-commits mailing list