[clang] 0cf4cb4 - Revert "[clang] Fix FIXME in dynamic initializer emission, NFCI"

Martin Storsjö via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 1 01:14:24 PDT 2024


Author: Martin Storsjö
Date: 2024-10-01T11:14:11+03:00
New Revision: 0cf4cb4bde440586c310554d93dc09e47cb9bb79

URL: https://github.com/llvm/llvm-project/commit/0cf4cb4bde440586c310554d93dc09e47cb9bb79
DIFF: https://github.com/llvm/llvm-project/commit/0cf4cb4bde440586c310554d93dc09e47cb9bb79.diff

LOG: Revert "[clang] Fix FIXME in dynamic initializer emission, NFCI"

This reverts commit 601645c3b70e2a17d18779a3a51b8bc9ecdc9aa6.

This change wasn't NFC in practice, see
https://github.com/llvm/llvm-project/issues/110232 for details.

Added: 
    

Modified: 
    clang/lib/CodeGen/CGDeclCXX.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index c44f38ef02a3f1..8dcb5f61006196 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 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.
+    // 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?
     llvm::Comdat *C = Addr->getComdat();
-    if (COMDATKey && C && getTriple().supportsCOMDAT() &&
-        !getTarget().getCXXABI().isMicrosoft()) {
+    if (COMDATKey && C &&
+        (getTarget().getTriple().isOSBinFormatELF() ||
+         getTarget().getTriple().isOSBinFormatWasm())) {
       Fn->setComdat(C);
     }
   } else {


        


More information about the cfe-commits mailing list