aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm
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 /include/llvm
parent7c856c09cd5a2d6231d2f03e383bbc165833df8c (diff)
downloadexternal_llvm-d0c1e29aecdaaa67ffabbaf2dd255809e6df4978.zip
external_llvm-d0c1e29aecdaaa67ffabbaf2dd255809e6df4978.tar.gz
external_llvm-d0c1e29aecdaaa67ffabbaf2dd255809e6df4978.tar.bz2
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 'include/llvm')
-rw-r--r--include/llvm/Target/ELFTargetAsmInfo.h2
-rw-r--r--include/llvm/Target/TargetAsmInfo.h15
2 files changed, 15 insertions, 2 deletions
diff --git a/include/llvm/Target/ELFTargetAsmInfo.h b/include/llvm/Target/ELFTargetAsmInfo.h
index fe339f8..3dacb33 100644
--- a/include/llvm/Target/ELFTargetAsmInfo.h
+++ b/include/llvm/Target/ELFTargetAsmInfo.h
@@ -27,7 +27,7 @@ namespace llvm {
explicit ELFTargetAsmInfo(const TargetMachine &TM);
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const;
- virtual std::string PrintSectionFlags(unsigned flags) const;
+ virtual std::string printSectionFlags(unsigned flags) const;
const Section* MergeableConstSection(const GlobalVariable *GV) const;
inline const Section* MergeableConstSection(const Type *Ty) const;
const Section* MergeableStringSection(const GlobalVariable *GV) const;
diff --git a/include/llvm/Target/TargetAsmInfo.h b/include/llvm/Target/TargetAsmInfo.h
index 04e91cb..8eb9515 100644
--- a/include/llvm/Target/TargetAsmInfo.h
+++ b/include/llvm/Target/TargetAsmInfo.h
@@ -16,6 +16,7 @@
#ifndef LLVM_TARGET_ASM_INFO_H
#define LLVM_TARGET_ASM_INFO_H
+#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/DataTypes.h"
#include <string>
@@ -83,6 +84,16 @@ namespace llvm {
static inline unsigned setEntitySize(unsigned Flags, unsigned Size) {
return ((Flags & ~EntitySize) | ((Size & 0xFF) << 24));
}
+
+ struct KeyInfo {
+ static inline unsigned getEmptyKey() { return Invalid; }
+ static inline unsigned getTombstoneKey() { return Invalid - 1; }
+ static unsigned getHashValue(const unsigned &Key) { return Key; }
+ static bool isEqual(unsigned LHS, unsigned RHS) { return LHS == RHS; }
+ static bool isPod() { return true; }
+ };
+
+ typedef DenseMap<unsigned, std::string, KeyInfo> FlagsStringsMapType;
}
class TargetMachine;
@@ -109,6 +120,7 @@ namespace llvm {
class TargetAsmInfo {
private:
mutable StringMap<Section> Sections;
+ mutable SectionFlags::FlagsStringsMapType FlagsStrings;
protected:
//===------------------------------------------------------------------===//
// Properties to be set by the target writer, used to configure asm printer.
@@ -551,7 +563,8 @@ namespace llvm {
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
SectionKind::Kind kind) const;
- virtual std::string PrintSectionFlags(unsigned flags) const { return ""; }
+ const std::string& getSectionFlags(unsigned Flags) const;
+ virtual std::string printSectionFlags(unsigned flags) const { return ""; }
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const;