[all-commits] [llvm/llvm-project] 3adb89: [ThinLTO] Make cloneUsedGlobalVariables deterministic

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Feb 23 16:09:25 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3adb89bb9f8e73c82787babb2f877fece7394770
      https://github.com/llvm/llvm-project/commit/3adb89bb9f8e73c82787babb2f877fece7394770
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-02-23 (Tue, 23 Feb 2021)

  Changed paths:
    M llvm/include/llvm/IR/Module.h
    M llvm/lib/IR/Module.cpp
    M llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp

  Log Message:
  -----------
  [ThinLTO] Make cloneUsedGlobalVariables deterministic

Iterating on `SmallPtrSet<GlobalValue *, 8>` with more than 8 elements
is not deterministic. Use a SmallVector instead because `Used` is guaranteed to contain unique elements.

While here, decrease inline element counts from 8 to 4. The number of
`llvm.used`/`llvm.compiler.used` elements is usually 0 or 1. For full
LTO/hybrid LTO, the number may be large, so we need to be careful.

According to tejohnson's analysis https://reviews.llvm.org/D97128#2582399 , 4 is
good for a large project with WholeProgramDevirt, when available_externally
vtables are placed in the llvm.compiler.used set.

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


  Commit: ed02f52d288fb4d8f9049868afa6af84a980cbc3
      https://github.com/llvm/llvm-project/commit/ed02f52d288fb4d8f9049868afa6af84a980cbc3
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-02-23 (Tue, 23 Feb 2021)

  Changed paths:
    M llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
    M llvm/lib/Transforms/IPO/LowerTypeTests.cpp

  Log Message:
  -----------
  Fix unstable SmallPtrSet iteration issues due to collectUsedGlobalVariables

While here, decrease inline element counts from 8 to 4. See D97128 for the choice.

Depends on D97128 (which added a new SmallVecImpl overload for collectUsedGlobalVariables).

Reviewed By: tejohnson

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


  Commit: ef312951fd6b4a255baf3cff27439c9ed8751651
      https://github.com/llvm/llvm-project/commit/ef312951fd6b4a255baf3cff27439c9ed8751651
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-02-23 (Tue, 23 Feb 2021)

  Changed paths:
    M llvm/include/llvm/IR/Module.h
    M llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h
    M llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
    M llvm/lib/IR/Module.cpp
    M llvm/lib/Object/IRSymtab.cpp
    M llvm/lib/Transforms/IPO/GlobalOpt.cpp
    M llvm/lib/Transforms/IPO/Internalize.cpp

  Log Message:
  -----------
  collectUsedGlobalVariables: migrate SmallPtrSetImpl overload to SmallVecImpl overload after D97128

And delete the SmallPtrSetImpl overload.

While here, decrease inline element counts from 8 to 4. See D97128 for the choice.

Reviewed By: tejohnson

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


Compare: https://github.com/llvm/llvm-project/compare/0a5949dcfa31...ef312951fd6b


More information about the All-commits mailing list