summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Stellard <tstellar@redhat.com>2018-11-29 23:40:59 +0000
committerTom Stellard <tstellar@redhat.com>2018-11-29 23:40:59 +0000
commit958b37efa2ef8d85ad94035410749bf330e6c7f4 (patch)
treef4e889a9a60890eaada3f698c42f0d7ee8eadfcb
parent938be89e4e11e14331d8616d7e49c02937928f9e (diff)
downloadbcm5719-llvm-958b37efa2ef8d85ad94035410749bf330e6c7f4.tar.gz
bcm5719-llvm-958b37efa2ef8d85ad94035410749bf330e6c7f4.zip
Merging r347431:
------------------------------------------------------------------------ r347431 | rnk | 2018-11-21 14:01:10 -0800 (Wed, 21 Nov 2018) | 12 lines [mingw] Use unmangled name after the $ in the section name GCC does it this way, and we have to be consistent. This includes stdcall and fastcall functions with suffixes. I confirmed that a fastcall function named "foo" ends up in ".text$foo", not ".text$@foo@8". Based on a patch by Andrew Yohn! Fixes PR39218. Differential Revision: https://reviews.llvm.org/D54762 ------------------------------------------------------------------------ llvm-svn: 347931
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp5
-rw-r--r--llvm/test/CodeGen/X86/mingw-comdats.ll33
2 files changed, 28 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index f6b91a2f023..16140f0b12b 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1156,10 +1156,11 @@ MCSection *TargetLoweringObjectFileCOFF::SelectSectionForGlobal(
MCSymbol *Sym = TM.getSymbol(ComdatGV);
StringRef COMDATSymName = Sym->getName();
- // Append "$symbol" to the section name when targetting mingw. The ld.bfd
+ // 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 (getTargetTriple().isWindowsGNUEnvironment())
- raw_svector_ostream(Name) << '$' << COMDATSymName;
+ raw_svector_ostream(Name) << '$' << ComdatGV->getName();
return getContext().getCOFFSection(Name, Characteristics, Kind,
COMDATSymName, Selection, UniqueID);
diff --git a/llvm/test/CodeGen/X86/mingw-comdats.ll b/llvm/test/CodeGen/X86/mingw-comdats.ll
index 2e9ebd8c9fc..35f4fd12670 100644
--- a/llvm/test/CodeGen/X86/mingw-comdats.ll
+++ b/llvm/test/CodeGen/X86/mingw-comdats.ll
@@ -1,13 +1,14 @@
-; 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
+; 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=i686-w64-windows-gnu < %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
; GCC and MSVC handle comdats completely differently. Make sure we do the right
; thing for each.
-; Generated with this C++ source:
+; Modeled on this C++ source, with additional modifications for
+; -ffunction-sections:
; int bar(int);
; __declspec(selectany) int gv = 42;
; inline int foo(int x) { return bar(x) + gv; }
@@ -26,8 +27,24 @@ entry:
ret i32 %call
}
+; CHECK: .section .text,"xr",one_only,main
; CHECK: main:
+; GNU: .section .text$main,"xr",one_only,main
; GNU: main:
+; GNU32: .section .text$main,"xr",one_only,_main
+; GNU32: _main:
+
+define dso_local x86_fastcallcc i32 @fastcall(i32 %x, i32 %y) {
+ %rv = add i32 %x, %y
+ ret i32 %rv
+}
+
+; CHECK: .section .text,"xr",one_only,fastcall
+; CHECK: fastcall:
+; GNU: .section .text$fastcall,"xr",one_only,fastcall
+; GNU: fastcall:
+; GNU32: .section .text$fastcall,"xr",one_only,@fastcall@8
+; GNU32: @fastcall@8:
; Function Attrs: inlinehint uwtable
define linkonce_odr dso_local i32 @_Z3fooi(i32 %x) #1 comdat {
@@ -50,9 +67,9 @@ entry:
; GNU: gv:
; GNU: .long 42
-; GNU32: .section .text$__Z3fooi,"xr",discard,__Z3fooi
+; GNU32: .section .text$_Z3fooi,"xr",discard,__Z3fooi
; GNU32: __Z3fooi:
-; GNU32: .section .data$_gv,"dw",discard,_gv
+; GNU32: .section .data$gv,"dw",discard,_gv
; GNU32: _gv:
; GNU32: .long 42
OpenPOWER on IntegriCloud