summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-06-24 16:01:53 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-06-24 16:01:53 +0000
commit102ff69693f8b6956018b74ea6898c9e953b6c00 (patch)
tree0cf624157c498cfa85c457bec57e3ac84c0af5a0 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parentc6308f59b29f530a3f71c719153478233a678a25 (diff)
downloadbcm5719-llvm-102ff69693f8b6956018b74ea6898c9e953b6c00.tar.gz
bcm5719-llvm-102ff69693f8b6956018b74ea6898c9e953b6c00.zip
CodeGen: Avoid multiple strlen calls
Use a StringRef to hold our section prefix. This avoids multiple calls to strlen. llvm-svn: 211602
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 02abc282e6d..9cef50e3751 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -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;
}
OpenPOWER on IntegriCloud