[PATCH] D108680: PR48030: Fix COMDAT-related linking problem with C++ thread_local static data members.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 24 18:40:56 PDT 2021


rsmith created this revision.
rsmith added a reviewer: rjmccall.
rsmith requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.
Herald added a project: clang.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108680

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108680.368528.patch
Type: text/x-patch
Size: 7341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210825/d065a424/attachment.bin>


More information about the cfe-commits mailing list