diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-12-01 04:40:32 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-12-01 04:40:32 +0000 |
commit | d0cf77ad590633c0e10336e4c59b509140328042 (patch) | |
tree | 0ef643f5ab912f6787aad2d1f9fe33c9f686fbd2 | |
parent | 11e571c95403c73dc8d12d91a4da2a989c4ccbf5 (diff) | |
download | external_llvm-d0cf77ad590633c0e10336e4c59b509140328042.zip external_llvm-d0cf77ad590633c0e10336e4c59b509140328042.tar.gz external_llvm-d0cf77ad590633c0e10336e4c59b509140328042.tar.bz2 |
--- Reverse-merging r195823 into '.':
U lib/MC/MCSectionCOFF.cpp
U lib/CodeGen/TargetLoweringObjectFileImpl.cpp
U test/MC/COFF/weak-symbol.ll
U test/MC/COFF/tricky-names.ll
G .
--- Recording mergeinfo for reverse merge of r195823 into '.':
G .
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@196036 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 38 | ||||
-rw-r--r-- | lib/MC/MCSectionCOFF.cpp | 23 | ||||
-rw-r--r-- | test/MC/COFF/tricky-names.ll | 6 | ||||
-rw-r--r-- | test/MC/COFF/weak-symbol.ll | 18 |
4 files changed, 44 insertions, 41 deletions
diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 229ccfa..59d7b57 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -723,31 +723,33 @@ getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const { int Selection = 0; unsigned Characteristics = getCOFFSectionFlags(Kind); - StringRef Name = GV->getSection(); - StringRef COMDATSymName = ""; + SmallString<128> Name(GV->getSection().c_str()); if (GV->isWeakForLinker()) { Selection = COFF::IMAGE_COMDAT_SELECT_ANY; Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT; - MCSymbol *Sym = getSymbol(*Mang, GV); - COMDATSymName = Sym->getName(); + Name.append("$"); + Mang->getNameWithPrefix(Name, GV, false, false); } return getContext().getCOFFSection(Name, Characteristics, Kind, - COMDATSymName, + "", Selection); } -static const char *getCOFFSectionNameForUniqueGlobal(SectionKind Kind) { +static const char *getCOFFSectionPrefixForUniqueGlobal(SectionKind Kind) { if (Kind.isText()) - return ".text"; + return ".text$"; if (Kind.isBSS ()) - return ".bss"; - if (Kind.isThreadLocal()) - return ".tls"; + return ".bss$"; + if (Kind.isThreadLocal()) { + // 'LLVM' is just an arbitary string to ensure that the section name gets + // sorted in between '.tls$AAA' and '.tls$ZZZ' by the linker. + return ".tls$LLVM"; + } if (Kind.isWriteable()) - return ".data"; - return ".rdata"; + return ".data$"; + return ".rdata$"; } @@ -758,14 +760,16 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, // If this global is linkonce/weak and the target handles this by emitting it // into a 'uniqued' section name, create and return the section now. if (GV->isWeakForLinker()) { - const char *Name = getCOFFSectionNameForUniqueGlobal(Kind); + const char *Prefix = getCOFFSectionPrefixForUniqueGlobal(Kind); + SmallString<128> Name(Prefix, Prefix+strlen(Prefix)); + Mang->getNameWithPrefix(Name, GV, false, false); + unsigned Characteristics = getCOFFSectionFlags(Kind); Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT; - MCSymbol *Sym = getSymbol(*Mang, GV); - return getContext().getCOFFSection(Name, Characteristics, - Kind, Sym->getName(), - COFF::IMAGE_COMDAT_SELECT_ANY); + + return getContext().getCOFFSection(Name.str(), Characteristics, + Kind, "", COFF::IMAGE_COMDAT_SELECT_ANY); } if (Kind.isText()) diff --git a/lib/MC/MCSectionCOFF.cpp b/lib/MC/MCSectionCOFF.cpp index bb35027..64aa2c5 100644 --- a/lib/MC/MCSectionCOFF.cpp +++ b/lib/MC/MCSectionCOFF.cpp @@ -20,8 +20,6 @@ MCSectionCOFF::~MCSectionCOFF() {} // anchor. // should be printed before the section name bool MCSectionCOFF::ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const { - if (COMDATSymbol) - return false; // FIXME: Does .section .bss/.data/.text work everywhere?? if (Name == ".text" || Name == ".data" || Name == ".bss") @@ -60,41 +58,36 @@ void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI, OS << 'r'; if (getCharacteristics() & COFF::IMAGE_SCN_MEM_DISCARDABLE) OS << 'n'; - - OS << '"'; + OS << "\"\n"; if (getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT) { - OS << ","; switch (Selection) { case COFF::IMAGE_COMDAT_SELECT_NODUPLICATES: - OS << "one_only,"; + OS << "\t.linkonce one_only\n"; break; case COFF::IMAGE_COMDAT_SELECT_ANY: - OS << "discard,"; + OS << "\t.linkonce discard\n"; break; case COFF::IMAGE_COMDAT_SELECT_SAME_SIZE: - OS << "same_size,"; + OS << "\t.linkonce same_size\n"; break; case COFF::IMAGE_COMDAT_SELECT_EXACT_MATCH: - OS << "same_contents,"; + OS << "\t.linkonce same_contents\n"; break; case COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE: - OS << "associative " << Assoc->getSectionName() << ","; + OS << "\t.linkonce associative " << Assoc->getSectionName() << "\n"; break; case COFF::IMAGE_COMDAT_SELECT_LARGEST: - OS << "largest,"; + OS << "\t.linkonce largest\n"; break; case COFF::IMAGE_COMDAT_SELECT_NEWEST: - OS << "newest,"; + OS << "\t.linkonce newest\n"; break; default: assert (0 && "unsupported COFF selection type"); break; } - assert(COMDATSymbol); - OS << *COMDATSymbol; } - OS << '\n'; } bool MCSectionCOFF::UseCodeAlign() const { diff --git a/test/MC/COFF/tricky-names.ll b/test/MC/COFF/tricky-names.ll index 458aa41..6e041d3 100644 --- a/test/MC/COFF/tricky-names.ll +++ b/test/MC/COFF/tricky-names.ll @@ -25,11 +25,11 @@ define weak i32 @"\01??_B?$num_put@_WV?$back_insert_iterator@V?$basic_string@_WU ; ASM-NOT: .globl "@foo.bar" ; READOBJ: Symbol -; READOBJ: Name: .text -; READOBJ: Section: .text +; READOBJ: Name: .text$??_B?$num_put@_WV?$back_insert_iterator@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@std@@@std@@51 +; READOBJ: Section: .text$??_B?$num_put@_WV?$back_insert_iterator@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@std@@@std@@51 ; READOBJ: Symbol ; READOBJ: Name: ??_B?$num_put@_WV?$back_insert_iterator@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@std@@@std@@51 -; READOBJ: Section: .text +; READOBJ: Section: .text$??_B?$num_put@_WV?$back_insert_iterator@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@std@@@std@@51 ; READOBJ: Symbol ; READOBJ: Name: ??__E_Generic_object@?$_Error_objects@H@std@@YAXXZ ; READOBJ: Symbol diff --git a/test/MC/COFF/weak-symbol.ll b/test/MC/COFF/weak-symbol.ll index f23063e..7f2e87c 100644 --- a/test/MC/COFF/weak-symbol.ll +++ b/test/MC/COFF/weak-symbol.ll @@ -8,31 +8,37 @@ ; RUN: llc -mtriple=x86_64-pc-mingw32 %s -o - | FileCheck %s --check-prefix=X64
; Mangled function
-; X86: .section .text,"xr",discard,__Z3foo
+; X86: .section .text$_Z3foo
+; X86: .linkonce discard
; X86: .globl __Z3foo
;
-; X64: .section .text,"xr",discard,_Z3foo
+; X64: .section .text$_Z3foo
+; X64: .linkonce discard
; X64: .globl _Z3foo
define weak void @_Z3foo() {
ret void
}
; Unmangled function
-; X86: .section .sect,"xr",discard,_f
+; X86: .section .sect$f
+; X86: .linkonce discard
; X86: .globl _f
;
-; X64: .section .sect,"xr",discard,f
+; X64: .section .sect$f
+; X64: .linkonce discard
; X64: .globl f
define weak void @f() section ".sect" {
ret void
}
; Weak global
-; X86: .section .data,"r",discard,_a
+; X86: .section .data$a
+; X86: .linkonce discard
; X86: .globl _a
; X86: .zero 12
;
-; X64: .section .data,"r",discard,a
+; X64: .section .data$a
+; X64: .linkonce discard
; X64: .globl a
; X64: .zero 12
@a = weak unnamed_addr constant { i32, i32, i32 } { i32 0, i32 0, i32 0}, section ".data"
|