aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/TargetAsmInfo.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2008-08-16 12:57:07 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2008-08-16 12:57:07 +0000
commitd0c1e29aecdaaa67ffabbaf2dd255809e6df4978 (patch)
treef207965577f57eaf26ff89b567c88f8a9f66caf6 /lib/Target/TargetAsmInfo.cpp
parent7c856c09cd5a2d6231d2f03e383bbc165833df8c (diff)
Reduce heap trashing due to std::string construction / concatenation via caching of section flags string representations
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54842 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetAsmInfo.cpp')
-rw-r--r--lib/Target/TargetAsmInfo.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp
index 9bc0b4055e..1ef2182033 100644
--- a/lib/Target/TargetAsmInfo.cpp
+++ b/lib/Target/TargetAsmInfo.cpp
@@ -291,7 +291,7 @@ TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
// If section is named we need to switch into it via special '.section'
// directive and also append funky flags. Otherwise - section name is just
// some magic assembler directive.
- return getSwitchToSectionDirective() + S->Name + PrintSectionFlags(S->Flags);
+ return getSwitchToSectionDirective() + S->Name + getSectionFlags(S->Flags);
}
// Lame default implementation. Calculate the section name for global.
@@ -376,3 +376,16 @@ TargetAsmInfo::getUnnamedSection(const char *Directive, unsigned Flags) const {
return &S;
}
+
+const std::string&
+TargetAsmInfo::getSectionFlags(unsigned Flags) const {
+ SectionFlags::FlagsStringsMapType::iterator I = FlagsStrings.find(Flags);
+
+ // We didn't print these flags yet, print and save them to map. This reduces
+ // amount of heap trashing due to std::string construction / concatenation.
+ if (I == FlagsStrings.end())
+ I = FlagsStrings.insert(std::make_pair(Flags,
+ printSectionFlags(Flags))).first;
+
+ return I->second;
+}