MC: Skip names of temporary symbols in object streamer
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 6 May 2015 21:34:34 +0000 (21:34 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 6 May 2015 21:34:34 +0000 (21:34 +0000)
Don't create names for temporary symbols when using an object streamer.
The names never make it to the output anyway.  From the starting point
of r236629, my heap profile says this drops peak memory usage from 1100
MB to 1058 MB for CodeGen of `verify-uselistorder`, a savings of almost
4% on peak memory, and removes `StringMap<bool, BumpPtrAllocator...>`
from the profile entirely.

(I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
see r236629 for details.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236642 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCContext.h
lib/CodeGen/LLVMTargetMachine.cpp
lib/MC/MCContext.cpp

index c714f651737825a5f84841d1403b6899c1852081..5a3ca29c0cd972da36f4783304f5936badc2615b 100644 (file)
@@ -158,6 +158,7 @@ namespace llvm {
     /// differences between temporary and non-temporary labels (primarily on
     /// Darwin).
     bool AllowTemporaryLabels;
+    bool UseNamesOnTempLabels = true;
 
     /// The Compile Unit ID that we are currently processing.
     unsigned DwarfCompileUnitID;
@@ -224,6 +225,7 @@ namespace llvm {
     const MCObjectFileInfo *getObjectFileInfo() const { return MOFI; }
 
     void setAllowTemporaryLabels(bool Value) { AllowTemporaryLabels = Value; }
+    void setUseNamesOnTempLabels(bool Value) { UseNamesOnTempLabels = Value; }
 
     /// \name Module Lifetime Management
     /// @{
index 61d68f607111ffd071e8916a758f361144133901..610c9f47bac7c88c228270d69ccb657dbec4654b 100644 (file)
@@ -198,6 +198,9 @@ bool LLVMTargetMachine::addPassesToEmitFile(
     if (!MCE || !MAB)
       return true;
 
+    // Don't waste memory on names of temp labels.
+    Context->setUseNamesOnTempLabels(false);
+
     Triple T(getTargetTriple());
     AsmStreamer.reset(getTarget().createMCObjectStreamer(
         T, *Context, *MAB, Out, MCE, STI, Options.MCOptions.MCRelaxAll,
index fd0422daf2935063f7a49bb2c879c5246b3f0680..d6f6dbb04fe980825effa50a21a981d4c1594827 100644 (file)
@@ -150,6 +150,9 @@ MCSymbol *MCContext::CreateSymbol(StringRef Name, bool AlwaysAddSuffix) {
   if (AllowTemporaryLabels)
     IsTemporary = Name.startswith(MAI->getPrivateGlobalPrefix());
 
+  if (IsTemporary && AlwaysAddSuffix && !UseNamesOnTempLabels)
+    return new (*this) MCSymbol("", true);
+
   SmallString<128> NewName = Name;
   bool AddSuffix = AlwaysAddSuffix;
   unsigned &NextUniqueID = NextID[Name];