[all-commits] [llvm/llvm-project] 7cbe04: COFF/ELF: Place llvm.global_ctors elements in llvm...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Aug 3 17:18:37 PDT 2021


  Branch: refs/heads/release/13.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 7cbe047bafe8951702011d030b055dfa2ec62ea2
      https://github.com/llvm/llvm-project/commit/7cbe047bafe8951702011d030b055dfa2ec62ea2
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-08-03 (Tue, 03 Aug 2021)

  Changed paths:
    M clang/lib/CodeGen/CGDeclCXX.cpp
    M clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
    M clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp

  Log Message:
  -----------
  COFF/ELF: Place llvm.global_ctors elements in llvm.used if comdat is used

On ELF, an SHT_INIT_ARRAY outside a section group is a GC root. The current
codegen abuses SHT_INIT_ARRAY in a section group to mean a GC root.

On PE/COFF, the dynamic initialization for `__declspec(selectany)` in a comdat
can be garbage collected by `-opt:ref`.

Call `addUsedGlobal` for the two cases to fix the abuse/bug.

Reviewed By: rnk

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

(cherry picked from commit 828767f325b5dd0356c5fd90e40a1c047010853e)




More information about the All-commits mailing list