From ece3f0021cd16518977b6b78af7bb3bfa19c089c Mon Sep 17 00:00:00 2001 From: Yaron Keren Date: Thu, 3 Sep 2015 20:33:29 +0000 Subject: [PATCH] =?utf8?q?Fix=20PR23472=C3=BE=20by=20emitting=20initialize?= =?utf8?q?d=20variable=20and=20its=20guard=20in=20the=20same=20COMDAT=20on?= =?utf8?q?ly=20for=20ELF=20objects.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/ItaniumCXXABI.cpp b/lib/CodeGen/ItaniumCXXABI.cpp index 751c472794..9fa4f06338 100644 --- a/lib/CodeGen/ItaniumCXXABI.cpp +++ b/lib/CodeGen/ItaniumCXXABI.cpp @@ -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()) { -- 2.50.1