Skip to content

Commit a45e71c

Browse files
committed
[Cygwin] Emit COMDAT name correctly for Cygwin
Cygwin-gcc emits COMDAT in the same format as MinGW-gcc.
1 parent 7aabf47 commit a45e71c

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@ MCSection *TargetLoweringObjectFileCOFF::SelectSectionForGlobal(
18301830
// Append "$symbol" to the section name *before* IR-level mangling is
18311831
// applied when targetting mingw. This is what GCC does, and the ld.bfd
18321832
// COFF linker will not properly handle comdats otherwise.
1833-
if (getContext().getTargetTriple().isWindowsGNUEnvironment())
1833+
if (getContext().getTargetTriple().isOSCygMing())
18341834
raw_svector_ostream(Name) << '$' << ComdatGV->getName();
18351835

18361836
return getContext().getCOFFSection(Name, Characteristics, COMDATSymName,

llvm/test/CodeGen/X86/mingw-comdats-xdata.ll

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
; RUN: llc -mtriple=x86_64-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU
2+
; RUN: llc -mtriple=x86_64-pc-cygwin < %s | FileCheck %s --check-prefix=GNU
23
; RUN: llc -mtriple=x86_64-w64-windows-gnu < %s -filetype=obj | llvm-objdump - --headers | FileCheck %s --check-prefix=GNUOBJ
4+
; RUN: llc -mtriple=x86_64-pc-cygwin < %s -filetype=obj | llvm-objdump - --headers | FileCheck %s --check-prefix=GNUOBJ
35

46
; When doing GCC style comdats for MinGW, the .xdata sections don't have a normal comdat
57
; symbol attached, which requires a bit of adjustments for the assembler output.

llvm/test/CodeGen/X86/mingw-comdats.ll

+2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
; RUN: llc -function-sections -mtriple=x86_64-windows-itanium < %s | FileCheck %s
22
; RUN: llc -function-sections -mtriple=x86_64-windows-msvc < %s | FileCheck %s
33
; RUN: llc -function-sections -mtriple=x86_64-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU
4+
; RUN: llc -function-sections -mtriple=x86_64-pc-cygwin < %s | FileCheck %s --check-prefix=GNU
45
; RUN: llc -function-sections -mtriple=i686-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU32
56
; RUN: llc -function-sections -mtriple=x86_64-w64-windows-gnu < %s -filetype=obj | llvm-objdump - --headers | FileCheck %s --check-prefix=GNUOBJ
7+
; RUN: llc -function-sections -mtriple=x86_64-pc-cygwin < %s -filetype=obj | llvm-objdump - --headers | FileCheck %s --check-prefix=GNUOBJ
68

79
; GCC and MSVC handle comdats completely differently. Make sure we do the right
810
; thing for each.

0 commit comments

Comments
 (0)