r218313 - Revert "Don't use comdats for initializers on platforms that don't support it"
Reid Kleckner
reid at kleckner.net
Tue Sep 23 09:20:02 PDT 2014
Author: rnk
Date: Tue Sep 23 11:20:01 2014
New Revision: 218313
URL: http://llvm.org/viewvc/llvm-project?rev=218313&view=rev
Log:
Revert "Don't use comdats for initializers on platforms that don't support it"
On further investigation, COMDATs should work with .ctors, and the issue
I was hitting probably reproduces with .init_array.
This reverts commit r218287.
Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenCXX/static-data-member.cpp
cfe/trunk/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=218313&r1=218312&r2=218313&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Tue Sep 23 11:20:01 2014
@@ -302,7 +302,7 @@ CodeGenModule::EmitCXXGlobalVarDeclInitF
CodeGenFunction(*this).GenerateCXXGlobalVarDeclInitFunc(Fn, D, Addr,
PerformInit);
- llvm::GlobalVariable *Key = supportsCOMDATInitializers() ? Addr : nullptr;
+ llvm::GlobalVariable *Key = supportsCOMDAT() ? Addr : nullptr;
if (D->getTLSKind()) {
// FIXME: Should we support init_priority for thread_local?
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=218313&r1=218312&r2=218313&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Tue Sep 23 11:20:01 2014
@@ -601,7 +601,6 @@ public:
const TargetInfo &getTarget() const { return Target; }
const llvm::Triple &getTriple() const;
bool supportsCOMDAT() const;
- bool supportsCOMDATInitializers() const;
CGCXXABI &getCXXABI() const { return *ABI; }
llvm::LLVMContext &getLLVMContext() { return VMContext; }
Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=218313&r1=218312&r2=218313&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Tue Sep 23 11:20:01 2014
@@ -1668,8 +1668,7 @@ void ItaniumCXXABI::EmitGuardedInit(Code
// The ABI says: It is suggested that it be emitted in the same COMDAT group
// as the associated data object
- if (!D.isLocalVarDecl() && var->isWeakForLinker() &&
- CGM.supportsCOMDATInitializers()) {
+ if (!D.isLocalVarDecl() && var->isWeakForLinker() && CGM.supportsCOMDAT()) {
llvm::Comdat *C = CGM.getModule().getOrInsertComdat(var->getName());
guard->setComdat(C);
var->setComdat(C);
Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=218313&r1=218312&r2=218313&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Sep 23 11:20:01 2014
@@ -6877,14 +6877,6 @@ bool CodeGenModule::supportsCOMDAT() con
return !getTriple().isOSBinFormatMachO();
}
-bool CodeGenModule::supportsCOMDATInitializers() const {
- // We can only put initializers in comdat groups on ELF with .init_array and
- // COFF with .CRT$XCU.
- return supportsCOMDAT() &&
- ((getTriple().isOSBinFormatELF() && getCodeGenOpts().UseInitArray) ||
- (getTriple().isWindowsMSVCEnvironment()));
-}
-
const TargetCodeGenInfo &CodeGenModule::getTargetCodeGenInfo() {
if (TheTargetCodeGenInfo)
return *TheTargetCodeGenInfo;
Modified: cfe/trunk/test/CodeGenCXX/static-data-member.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-data-member.cpp?rev=218313&r1=218312&r2=218313&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/static-data-member.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/static-data-member.cpp Tue Sep 23 11:20:01 2014
@@ -1,8 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -fuse-init-array -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -o - %s | \
-// RUN: FileCheck %s --check-prefix=CTORS
+// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | \
-// RUN: FileCheck --check-prefix=MACHO %s
+// RUN: FileCheck --check-prefix=MACHO %s
// CHECK: @_ZN5test11A1aE = constant i32 10, align 4
// CHECK: @_ZN5test212_GLOBAL__N_11AIiE1xE = internal global i32 0, align 4
@@ -10,8 +8,6 @@
// CHECK: @_ZGVN5test31AIiE1xE = weak_odr global i64 0, comdat $_ZN5test31AIiE1xE
// MACHO: @_ZGVN5test31AIiE1xE = weak_odr global i64 0
// MACHO-NOT: comdat
-// CTORS: @_ZGVN5test31AIiE1xE = weak_odr global i64 0
-// CTORS-NOT: comdat
// CHECK: _ZN5test51U2k0E = global i32 0
// CHECK: _ZN5test51U2k1E = global i32 0
@@ -71,8 +67,6 @@ namespace test3 {
// CHECK-LABEL: define internal void @__cxx_global_var_init1() {{.*}} comdat $_ZN5test31AIiE1xE
// MACHO-LABEL: define internal void @__cxx_global_var_init1()
// MACHO-NOT: comdat
- // CTORS-LABEL: define internal void @__cxx_global_var_init1()
- // CTORS-NOT: comdat
// CHECK: [[GUARDBYTE:%.*]] = load i8* bitcast (i64* @_ZGVN5test31AIiE1xE to i8*)
// CHECK-NEXT: [[UNINITIALIZED:%.*]] = icmp eq i8 [[GUARDBYTE]], 0
// CHECK-NEXT: br i1 [[UNINITIALIZED]]
Modified: cfe/trunk/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp?rev=218313&r1=218312&r2=218313&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp Tue Sep 23 11:20:01 2014
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -std=c++1y -triple=x86_64-pc-linux -fuse-init-array -emit-llvm -o - | FileCheck --check-prefix=ELF --check-prefix=ALL %s
+// RUN: %clang_cc1 %s -std=c++1y -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=ELF --check-prefix=ALL %s
// RUN: %clang_cc1 %s -std=c++1y -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck --check-prefix=MACHO --check-prefix=ALL %s
// ALL: ; ModuleID
More information about the cfe-commits
mailing list