]> granicus.if.org Git - clang/commitdiff
Fix PR23472รพ by emitting initialized variable and its guard in the same COMDAT only...
authorYaron Keren <yaron.keren@gmail.com>
Thu, 3 Sep 2015 20:33:29 +0000 (20:33 +0000)
committerYaron Keren <yaron.keren@gmail.com>
Thu, 3 Sep 2015 20:33:29 +0000 (20:33 +0000)
 http://llvm.org/pr23472

Reviewed by Reid Kleckner.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246803 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/ItaniumCXXABI.cpp

index 751c47279489c9f27fceb301c333bd78d1ce0e57..9fa4f06338a40a8e27b72be22939eab51d7f96d9 100644 (file)
@@ -1823,10 +1823,12 @@ void ItaniumCXXABI::EmitGuardedInit(CodeGenFunction &CGF,
     // If the variable is thread-local, so is its guard variable.
     guard->setThreadLocalMode(var->getThreadLocalMode());
 
-    // The ABI says: It is suggested that it be emitted in the same COMDAT group
-    // as the associated data object
+    // The ABI says: "It is suggested that it be emitted in the same COMDAT
+    // group as the associated data object." In practice, this doesn't work for
+    // non-ELF object formats, so only do it for ELF.
     llvm::Comdat *C = var->getComdat();
-    if (!D.isLocalVarDecl() && C) {
+    if (!D.isLocalVarDecl() && C &&
+        CGM.getTarget().getTriple().isOSBinFormatELF()) {
       guard->setComdat(C);
       CGF.CurFn->setComdat(C);
     } else if (CGM.supportsCOMDAT() && guard->isWeakForLinker()) {