mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 19:25:00 +00:00
CodeGen: Avoid multiple strlen calls
Use a StringRef to hold our section prefix. This avoids multiple calls to strlen. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211602 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -207,7 +207,7 @@ const MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal(
|
|||||||
|
|
||||||
/// getSectionPrefixForGlobal - Return the section prefix name used by options
|
/// getSectionPrefixForGlobal - Return the section prefix name used by options
|
||||||
/// FunctionsSections and DataSections.
|
/// FunctionsSections and DataSections.
|
||||||
static const char *getSectionPrefixForGlobal(SectionKind Kind) {
|
static StringRef getSectionPrefixForGlobal(SectionKind Kind) {
|
||||||
if (Kind.isText()) return ".text.";
|
if (Kind.isText()) return ".text.";
|
||||||
if (Kind.isReadOnly()) return ".rodata.";
|
if (Kind.isReadOnly()) return ".rodata.";
|
||||||
if (Kind.isBSS()) return ".bss.";
|
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.
|
// into a 'uniqued' section name, create and return the section now.
|
||||||
if ((GV->isWeakForLinker() || EmitUniquedSection) &&
|
if ((GV->isWeakForLinker() || EmitUniquedSection) &&
|
||||||
!Kind.isCommon()) {
|
!Kind.isCommon()) {
|
||||||
const char *Prefix;
|
StringRef Prefix = getSectionPrefixForGlobal(Kind);
|
||||||
Prefix = getSectionPrefixForGlobal(Kind);
|
|
||||||
|
|
||||||
SmallString<128> Name(Prefix, Prefix+strlen(Prefix));
|
SmallString<128> Name(Prefix);
|
||||||
TM.getNameWithPrefix(Name, GV, Mang, true);
|
TM.getNameWithPrefix(Name, GV, Mang, true);
|
||||||
|
|
||||||
StringRef Group = "";
|
StringRef Group = "";
|
||||||
unsigned Flags = getELFSectionFlags(Kind);
|
unsigned Flags = getELFSectionFlags(Kind);
|
||||||
if (GV->isWeakForLinker()) {
|
if (GV->isWeakForLinker()) {
|
||||||
Group = Name.substr(strlen(Prefix));
|
Group = Name.substr(Prefix.size());
|
||||||
Flags |= ELF::SHF_GROUP;
|
Flags |= ELF::SHF_GROUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user