llvm.org GIT mirror llvm / f8ee49e
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 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_70@347931 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 1 year, 11 months ago
2 changed file(s) with 28 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
11551155 MCSymbol *Sym = TM.getSymbol(ComdatGV);
11561156 StringRef COMDATSymName = Sym->getName();
11571157
1158 // Append "$symbol" to the section name when targetting mingw. The ld.bfd
1158 // Append "$symbol" to the section name *before* IR-level mangling is
1159 // applied when targetting mingw. This is what GCC does, and the ld.bfd
11591160 // COFF linker will not properly handle comdats otherwise.
11601161 if (getTargetTriple().isWindowsGNUEnvironment())
1161 raw_svector_ostream(Name) << '$' << COMDATSymName;
1162 raw_svector_ostream(Name) << '$' << ComdatGV->getName();
11621163
11631164 return getContext().getCOFFSection(Name, Characteristics, Kind,
11641165 COMDATSymName, Selection, UniqueID);
None ; RUN: llc -mtriple=x86_64-windows-itanium < %s | FileCheck %s
1 ; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s
2 ; RUN: llc -mtriple=x86_64-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU
3 ; RUN: llc -mtriple=i686-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU32
4 ; RUN: llc -mtriple=x86_64-w64-windows-gnu < %s -filetype=obj | llvm-objdump - -headers | FileCheck %s --check-prefix=GNUOBJ
0 ; RUN: llc -function-sections -mtriple=x86_64-windows-itanium < %s | FileCheck %s
1 ; RUN: llc -function-sections -mtriple=x86_64-windows-msvc < %s | FileCheck %s
2 ; RUN: llc -function-sections -mtriple=x86_64-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU
3 ; RUN: llc -function-sections -mtriple=i686-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU32
4 ; RUN: llc -function-sections -mtriple=x86_64-w64-windows-gnu < %s -filetype=obj | llvm-objdump - -headers | FileCheck %s --check-prefix=GNUOBJ
55
66 ; GCC and MSVC handle comdats completely differently. Make sure we do the right
77 ; thing for each.
88
9 ; Generated with this C++ source:
9 ; Modeled on this C++ source, with additional modifications for
10 ; -ffunction-sections:
1011 ; int bar(int);
1112 ; __declspec(selectany) int gv = 42;
1213 ; inline int foo(int x) { return bar(x) + gv; }
2526 ret i32 %call
2627 }
2728
29 ; CHECK: .section .text,"xr",one_only,main
2830 ; CHECK: main:
31 ; GNU: .section .text$main,"xr",one_only,main
2932 ; GNU: main:
33 ; GNU32: .section .text$main,"xr",one_only,_main
34 ; GNU32: _main:
35
36 define dso_local x86_fastcallcc i32 @fastcall(i32 %x, i32 %y) {
37 %rv = add i32 %x, %y
38 ret i32 %rv
39 }
40
41 ; CHECK: .section .text,"xr",one_only,fastcall
42 ; CHECK: fastcall:
43 ; GNU: .section .text$fastcall,"xr",one_only,fastcall
44 ; GNU: fastcall:
45 ; GNU32: .section .text$fastcall,"xr",one_only,@fastcall@8
46 ; GNU32: @fastcall@8:
3047
3148 ; Function Attrs: inlinehint uwtable
3249 define linkonce_odr dso_local i32 @_Z3fooi(i32 %x) #1 comdat {
4966 ; GNU: gv:
5067 ; GNU: .long 42
5168
52 ; GNU32: .section .text$__Z3fooi,"xr",discard,__Z3fooi
69 ; GNU32: .section .text$_Z3fooi,"xr",discard,__Z3fooi
5370 ; GNU32: __Z3fooi:
54 ; GNU32: .section .data$_gv,"dw",discard,_gv
71 ; GNU32: .section .data$gv,"dw",discard,_gv
5572 ; GNU32: _gv:
5673 ; GNU32: .long 42
5774