[llvm] r211602 - CodeGen: Avoid multiple strlen calls
David Majnemer
david.majnemer at gmail.com
Tue Jun 24 09:01:53 PDT 2014
Author: majnemer
Date: Tue Jun 24 11:01:53 2014
New Revision: 211602
URL: http://llvm.org/viewvc/llvm-project?rev=211602&view=rev
Log:
CodeGen: Avoid multiple strlen calls
Use a StringRef to hold our section prefix. This avoids multiple calls
to strlen.
Modified:
llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=211602&r1=211601&r2=211602&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Tue Jun 24 11:01:53 2014
@@ -207,7 +207,7 @@ const MCSection *TargetLoweringObjectFil
/// 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
// 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;
}
More information about the llvm-commits
mailing list