[all-commits] [llvm/llvm-project] cd4d6d: PR48030: Fix COMDAT-related linking problem with C...

Richard Smith via All-commits all-commits at lists.llvm.org
Tue Aug 24 19:54:13 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cd4d6d718b2e51ed830a28d01d765da2a220afd3
      https://github.com/llvm/llvm-project/commit/cd4d6d718b2e51ed830a28d01d765da2a220afd3
  Author: Richard Smith <richard at metafoo.co.uk>
  Date:   2021-08-24 (Tue, 24 Aug 2021)

  Changed paths:
    M clang/lib/CodeGen/CGDeclCXX.cpp
    M clang/lib/CodeGen/ItaniumCXXABI.cpp
    A clang/test/CodeGenCXX/cxx11-thread-local-instantiated.cpp
    M clang/test/CodeGenCXX/cxx11-thread-local.cpp
    M clang/test/CodeGenCXX/cxx1z-inline-variables.cpp
    M clang/test/OpenMP/threadprivate_codegen.cpp

  Log Message:
  -----------
  PR48030: Fix COMDAT-related linking problem with C++ thread_local static data members.

Previously when emitting a C++ guarded initializer, we tried to work out what
the enclosing function would be used for and added it to the COMDAT containing
the variable if we thought that doing so would be correct. But this was done
from a context in which we didn't -- and realistically couldn't -- correctly
infer how the enclosing function would be used.

Instead, add the initialization function to a COMDAT from the code that
creates it, in the case where it makes sense to do so: when we know that
the one and only reference to the initialization function is in
@llvm.global.ctors and that reference is in the same COMDAT.

Reviewed By: rjmccall

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




More information about the All-commits mailing list