Don't try to use C5/D5 comdats in COFF.

This should fix the mingw bootstrap.

llvm-svn: 217897
This commit is contained in:
Rafael Espindola 2014-09-16 20:19:43 +00:00
parent 337188fdb8
commit 0806f982e0
2 changed files with 11 additions and 2 deletions

View File

@ -3029,8 +3029,12 @@ static StructorCodegen getCodegenToUse(CodeGenModule &CGM,
if (!llvm::GlobalAlias::isValidLinkage(Linkage))
return StructorCodegen::RAUW;
if (llvm::GlobalValue::isWeakForLinker(Linkage))
return StructorCodegen::COMDAT;
if (llvm::GlobalValue::isWeakForLinker(Linkage)) {
// Only ELF supports COMDATs with arbitrary names (C5/D5).
if (CGM.getTarget().getTriple().isOSBinFormatELF())
return StructorCodegen::COMDAT;
return StructorCodegen::Emit;
}
return StructorCodegen::Alias;
}

View File

@ -8,6 +8,8 @@
// RUN: FileCheck --check-prefix=CHECK5 --input-file=%t %s
// RUN: FileCheck --check-prefix=CHECK6 --input-file=%t %s
// RUN: %clang_cc1 %s -triple i686-pc-windows-gnu -emit-llvm -o - -mconstructor-aliases -O1 -disable-llvm-optzns | FileCheck --check-prefix=COFF %s
namespace test1 {
// Test that we produce the apropriate comdats when creating aliases to
// weak_odr constructors and destructors.
@ -19,6 +21,9 @@ namespace test1 {
// CHECK1: define weak_odr void @_ZN5test16foobarIvED0Ev({{.*}} comdat $_ZN5test16foobarIvED5Ev
// CHECK1-NOT: comdat
// COFF doesn't support comdats with arbitrary names (C5/D5).
// COFF-NOT: comdat
template <typename T>
struct foobar {
foobar() {}