1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

CodeGen: Avoid multiple strlen calls

Use a StringRef to hold our section prefix.  This avoids multiple calls
to strlen.

llvm-svn: 211602
This commit is contained in:
David Majnemer 2014-06-24 16:01:53 +00:00
parent 4deae9a4a4
commit 02a115bee2

View File

@ -207,7 +207,7 @@ const MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal(
/// getSectionPrefixForGlobal - Return the section prefix name used by options
/// FunctionsSections and DataSections.
static const char *getSectionPrefixForGlobal(SectionKind Kind) {
static StringRef getSectionPrefixForGlobal(SectionKind Kind) {
if (Kind.isText()) return ".text.";
if (Kind.isReadOnly()) return ".rodata.";
if (Kind.isBSS()) return ".bss.";
@ -240,16 +240,15 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
// into a 'uniqued' section name, create and return the section now.
if ((GV->isWeakForLinker() || EmitUniquedSection) &&
!Kind.isCommon()) {
const char *Prefix;
Prefix = getSectionPrefixForGlobal(Kind);
StringRef Prefix = getSectionPrefixForGlobal(Kind);
SmallString<128> Name(Prefix, Prefix+strlen(Prefix));
SmallString<128> Name(Prefix);
TM.getNameWithPrefix(Name, GV, Mang, true);
StringRef Group = "";
unsigned Flags = getELFSectionFlags(Kind);
if (GV->isWeakForLinker()) {
Group = Name.substr(strlen(Prefix));
Group = Name.substr(Prefix.size());
Flags |= ELF::SHF_GROUP;
}