summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h5
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp17
-rw-r--r--llvm/test/CodeGen/X86/mingw-comdats.ll8
3 files changed, 14 insertions, 16 deletions
diff --git a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
index 98df861dea0..626703e46f6 100644
--- a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
+++ b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
@@ -134,11 +134,6 @@ public:
class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
mutable unsigned NextUniqueID = 0;
- /// Append "$symbol" to the section name when targetting mingw. The ld.bfd
- /// COFF linker will not properly handle comdats otherwise.
- void appendComdatSymbolForMinGW(SmallVectorImpl<char> &SecName,
- StringRef Symbol, const DataLayout &DL) const;
-
public:
~TargetLoweringObjectFileCOFF() override = default;
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 8518ee7def3..df8aecd7cf4 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1072,15 +1072,6 @@ static StringRef getCOFFSectionNameForUniqueGlobal(SectionKind Kind) {
return ".data";
}
-void TargetLoweringObjectFileCOFF::appendComdatSymbolForMinGW(
- SmallVectorImpl<char> &SecName, StringRef Symbol,
- const DataLayout &DL) const {
- if (getTargetTriple().isWindowsGNUEnvironment()) {
- SecName.push_back('$');
- getMangler().getNameWithPrefix(SecName, Symbol, DL);
- }
-}
-
MCSection *TargetLoweringObjectFileCOFF::SelectSectionForGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
// If we have -ffunction-sections then we should emit the global value to a
@@ -1113,8 +1104,12 @@ MCSection *TargetLoweringObjectFileCOFF::SelectSectionForGlobal(
if (!ComdatGV->hasPrivateLinkage()) {
MCSymbol *Sym = TM.getSymbol(ComdatGV);
StringRef COMDATSymName = Sym->getName();
- appendComdatSymbolForMinGW(Name, COMDATSymName,
- GO->getParent()->getDataLayout());
+
+ // Append "$symbol" to the section name when targetting mingw. The ld.bfd
+ // COFF linker will not properly handle comdats otherwise.
+ if (getTargetTriple().isWindowsGNUEnvironment())
+ raw_svector_ostream(Name) << '$' << COMDATSymName;
+
return getContext().getCOFFSection(Name, Characteristics, Kind,
COMDATSymName, Selection, UniqueID);
} else {
diff --git a/llvm/test/CodeGen/X86/mingw-comdats.ll b/llvm/test/CodeGen/X86/mingw-comdats.ll
index 083885ae918..2e9ebd8c9fc 100644
--- a/llvm/test/CodeGen/X86/mingw-comdats.ll
+++ b/llvm/test/CodeGen/X86/mingw-comdats.ll
@@ -1,6 +1,7 @@
; RUN: llc -mtriple=x86_64-windows-itanium < %s | FileCheck %s
; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s
; RUN: llc -mtriple=x86_64-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU
+; RUN: llc -mtriple=i686-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU32
; RUN: llc -mtriple=x86_64-w64-windows-gnu < %s -filetype=obj | llvm-objdump - -headers | FileCheck %s --check-prefix=GNUOBJ
; GCC and MSVC handle comdats completely differently. Make sure we do the right
@@ -49,6 +50,13 @@ entry:
; GNU: gv:
; GNU: .long 42
+; GNU32: .section .text$__Z3fooi,"xr",discard,__Z3fooi
+; GNU32: __Z3fooi:
+; GNU32: .section .data$_gv,"dw",discard,_gv
+; GNU32: _gv:
+; GNU32: .long 42
+
+
; Make sure the assembler puts the .xdata and .pdata in sections with the right
; names.
; GNUOBJ: .text$_Z3fooi
OpenPOWER on IntegriCloud