summaryrefslogtreecommitdiff
path: root/lib/CodeGen
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
commitfde22c17f5e4dc2f93a0481fa95f89f8a633ba8a (patch)
treeeefe12ae4207e9d43d4bd6d587b367cb775d8e33 /lib/CodeGen
parent01c8340c3d2783034201e1431bb43f02bb0150b1 (diff)
downloadllvm-fde22c17f5e4dc2f93a0481fa95f89f8a633ba8a.tar.gz
llvm-fde22c17f5e4dc2f93a0481fa95f89f8a633ba8a.tar.bz2
llvm-fde22c17f5e4dc2f93a0481fa95f89f8a633ba8a.tar.xz
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
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/TargetLoweringObjectFileImpl.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 02abc282e6..9cef50e375 100644
--- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/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;
}