diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index c9415292e88f7..e1bdc7e09fdc0 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1830,7 +1830,7 @@ MCSection *TargetLoweringObjectFileCOFF::SelectSectionForGlobal( // Append "$symbol" to the section name *before* IR-level mangling is // applied when targetting mingw. This is what GCC does, and the ld.bfd // COFF linker will not properly handle comdats otherwise. - if (getContext().getTargetTriple().isWindowsGNUEnvironment()) + if (getContext().getTargetTriple().isOSCygMing()) raw_svector_ostream(Name) << '$' << ComdatGV->getName(); return getContext().getCOFFSection(Name, Characteristics, COMDATSymName, diff --git a/llvm/test/CodeGen/X86/mingw-comdats-xdata.ll b/llvm/test/CodeGen/X86/mingw-comdats-xdata.ll index 1a60c155b3c4d..0e914a89aee76 100644 --- a/llvm/test/CodeGen/X86/mingw-comdats-xdata.ll +++ b/llvm/test/CodeGen/X86/mingw-comdats-xdata.ll @@ -1,5 +1,7 @@ ; RUN: llc -mtriple=x86_64-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU +; RUN: llc -mtriple=x86_64-pc-cygwin < %s | FileCheck %s --check-prefix=GNU ; RUN: llc -mtriple=x86_64-w64-windows-gnu < %s -filetype=obj | llvm-objdump - --headers | FileCheck %s --check-prefix=GNUOBJ +; RUN: llc -mtriple=x86_64-pc-cygwin < %s -filetype=obj | llvm-objdump - --headers | FileCheck %s --check-prefix=GNUOBJ ; When doing GCC style comdats for MinGW, the .xdata sections don't have a normal comdat ; symbol attached, which requires a bit of adjustments for the assembler output. diff --git a/llvm/test/CodeGen/X86/mingw-comdats.ll b/llvm/test/CodeGen/X86/mingw-comdats.ll index bca8e12ea3c73..71e9503bdeb61 100644 --- a/llvm/test/CodeGen/X86/mingw-comdats.ll +++ b/llvm/test/CodeGen/X86/mingw-comdats.ll @@ -1,8 +1,11 @@ ; RUN: llc -function-sections -mtriple=x86_64-windows-itanium < %s | FileCheck %s ; RUN: llc -function-sections -mtriple=x86_64-windows-msvc < %s | FileCheck %s ; RUN: llc -function-sections -mtriple=x86_64-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU +; RUN: llc -function-sections -mtriple=x86_64-pc-cygwin < %s | FileCheck %s --check-prefix=GNU ; RUN: llc -function-sections -mtriple=i686-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU32 +; RUN: llc -function-sections -mtriple=i686-pc-cygwin < %s | FileCheck %s --check-prefix=GNU32 ; RUN: llc -function-sections -mtriple=x86_64-w64-windows-gnu < %s -filetype=obj | llvm-objdump - --headers | FileCheck %s --check-prefix=GNUOBJ +; RUN: llc -function-sections -mtriple=x86_64-pc-cygwin < %s -filetype=obj | llvm-objdump - --headers | FileCheck %s --check-prefix=GNUOBJ ; GCC and MSVC handle comdats completely differently. Make sure we do the right ; thing for each.