[all-commits] [llvm/llvm-project] 252a1e: [ThinLTO] Respect ClearDSOLocalOnDeclarations for ...

Fangrui Song via All-commits all-commits at lists.llvm.org
Fri Jul 2 17:08:40 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 252a1eecc04080d852ba58c6727970c688eb1619
      https://github.com/llvm/llvm-project/commit/252a1eecc04080d852ba58c6727970c688eb1619
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-07-02 (Fri, 02 Jul 2021)

  Changed paths:
    M llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
    A llvm/test/ThinLTO/X86/import-dsolocal.ll
    M llvm/test/ThinLTO/X86/index-const-prop-linkage.ll

  Log Message:
  -----------
  [ThinLTO] Respect ClearDSOLocalOnDeclarations for unimported functions

D74751 added `ClearDSOLocalOnDeclarations` and dropped dso_local for
isDeclarationForLinker `GlobalValue`s. It missed a case for imported
declarations (`doImportAsDefinition` is false while `isPerformingImport` is
true). This can lead to a linker error for a default visibility symbol in
`ld.lld -shared`.

When `ClearDSOLocalOnDeclarations` is true, we check
`isPerformingImport() && !doImportAsDefinition(&GV)` along with
`GV.isDeclarationForLinker()`. The new condition checks an imported declaration.

This patch fixes a `LLVMPolly.so` link error using a trunk clang -DLLVM_ENABLE_LTO=Thin.

Reviewed By: tejohnson

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




More information about the All-commits mailing list