diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-02-19 01:28:30 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-02-19 01:28:30 +0000 |
| commit | b9ea63c551f667af119cce25e1b5a59b8bbe8091 (patch) | |
| tree | e1d879ee81b6312f035044601fcd2d6179c5e6f0 | |
| parent | b32d009b4f51fcd6c055f88d4085620c7a040550 (diff) | |
| download | bcm5719-llvm-b9ea63c551f667af119cce25e1b5a59b8bbe8091.tar.gz bcm5719-llvm-b9ea63c551f667af119cce25e1b5a59b8bbe8091.zip | |
Avoid an infinite cycle with private linkage and -f{data|function}-sections.
When outputting an object we check its section to find its name, but when
looking for the section with -ffunction-section we look for the symbol name.
Break the loop by requesting a name with the private prefix when constructing
the section name. This matches the behavior before r201608.
llvm-svn: 201622
| -rw-r--r-- | llvm/include/llvm/Target/TargetLowering.h | 2 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/TargetLoweringBase.cpp | 5 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 6 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/global-sections.ll | 8 |
4 files changed, 15 insertions, 6 deletions
diff --git a/llvm/include/llvm/Target/TargetLowering.h b/llvm/include/llvm/Target/TargetLowering.h index d9db22ba1e1..155bb0a7a58 100644 --- a/llvm/include/llvm/Target/TargetLowering.h +++ b/llvm/include/llvm/Target/TargetLowering.h @@ -1338,7 +1338,7 @@ public: } void getNameWithPrefix(SmallVectorImpl<char> &Name, const GlobalValue *GV, - Mangler &Mang) const; + Mangler &Mang, bool MayAlwaysUsePrivate = false) const; MCSymbol *getSymbol(const GlobalValue *GV, Mangler &Mang) const; private: diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index a0ea3b3ba3b..d3c42be5e6c 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -1431,8 +1431,9 @@ bool TargetLoweringBase::isLegalAddressingMode(const AddrMode &AM, void TargetLoweringBase::getNameWithPrefix(SmallVectorImpl<char> &Name, const GlobalValue *GV, - Mangler &Mang) const { - if (!GV->hasPrivateLinkage()) { + Mangler &Mang, + bool MayAlwaysUsePrivate) const { + if (MayAlwaysUsePrivate || !GV->hasPrivateLinkage()) { // Simple case: If GV is not private, it is not important to find out if // private labels are legal in this case or not. Mang.getNameWithPrefix(Name, GV, false); diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 1bb483f0157..bd54a871ca3 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -248,12 +248,12 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Prefix = getSectionPrefixForGlobal(Kind); SmallString<128> Name(Prefix, Prefix+strlen(Prefix)); - MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang); - Name.append(Sym->getName().begin(), Sym->getName().end()); + TM.getTargetLowering()->getNameWithPrefix(Name, GV, Mang, true); + StringRef Group = ""; unsigned Flags = getELFSectionFlags(Kind); if (GV->isWeakForLinker()) { - Group = Sym->getName(); + Group = Name.substr(strlen(Prefix)); Flags |= ELF::SHF_GROUP; } diff --git a/llvm/test/CodeGen/X86/global-sections.ll b/llvm/test/CodeGen/X86/global-sections.ll index eaf7337214b..c031821f9a6 100644 --- a/llvm/test/CodeGen/X86/global-sections.ll +++ b/llvm/test/CodeGen/X86/global-sections.ll @@ -168,3 +168,11 @@ ; DARWIN: .zerofill __DATA,__common,_G12,1,3 ; DARWIN: .globl _G13 ; DARWIN: .zerofill __DATA,__common,_G13,1,3 + +@G14 = private unnamed_addr constant [4 x i8] c"foo\00", align 1 + +; LINUX-SECTIONS: .type .LG14,@object # @G14 +; LINUX-SECTIONS: .section .rodata..LG14,"aMS",@progbits,1 +; LINUX-SECTIONS: .LG14: +; LINUX-SECTIONS: .asciz "foo" +; LINUX-SECTIONS: .size .LG14, 4 |

