Author: Reid Kleckner Date: 2024-09-04T17:34:26Z New Revision: 601645c3b70e2a17d18779a3a51b8bc9ecdc9aa6
URL: https://github.com/llvm/llvm-project/commit/601645c3b70e2a17d18779a3a51b8bc9ecdc9aa6 DIFF: https://github.com/llvm/llvm-project/commit/601645c3b70e2a17d18779a3a51b8bc9ecdc9aa6.diff LOG: [clang] Fix FIXME in dynamic initializer emission, NFCI This potentially affects platforms that support comdats other than ELF, COFF, or wasm, but that is the intention of the FIXME, and if they don't want this behavior, they probably shouldn't advertise comdat support. Added: Modified: clang/lib/CodeGen/CGDeclCXX.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 8dcb5f61006196..c44f38ef02a3f1 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -640,13 +640,13 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, addUsedGlobal(COMDATKey); } - // If we used a COMDAT key for the global ctor, the init function can be - // discarded if the global ctor entry is discarded. - // FIXME: Do we need to restrict this to ELF and Wasm? + // If comdats are in use and supported, place the initializer function into + // the comdat group of the global. In the MS ABI, initializers are mangled + // and have their own comdat, so we don't include them in the group for + // consistency with MSVC. llvm::Comdat *C = Addr->getComdat(); - if (COMDATKey && C && - (getTarget().getTriple().isOSBinFormatELF() || - getTarget().getTriple().isOSBinFormatWasm())) { + if (COMDATKey && C && getTriple().supportsCOMDAT() && + !getTarget().getCXXABI().isMicrosoft()) { Fn->setComdat(C); } } else { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits