[llvm] r237823 - Use a SmallString buffer instead of a std::string for debug info path lookup. NFC.

Pete Cooper peter_cooper at apple.com
Wed May 20 12:12:15 PDT 2015


Author: pete
Date: Wed May 20 14:12:14 2015
New Revision: 237823

URL: http://llvm.org/viewvc/llvm-project?rev=237823&view=rev
Log:
Use a SmallString buffer instead of a std::string for debug info path lookup.  NFC.

This code appends the filename to the directory then looks that up in a StringMap.  We should be using the existing Twine::toStringRef method instead of Twine::str() as most times we'll succeed in the lookup.

Its possible that we should also consider allowing StringMap to lookup a key using a Twine in addition to a StringRef but that would complicate the code with little known benefit above and beyond this change.

This saves 170k temporary allocations when running llc on the verify_use_list_order bitcode with debug info for x86.

Modified:
    llvm/trunk/lib/MC/MCDwarf.cpp

Modified: llvm/trunk/lib/MC/MCDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=237823&r1=237822&r2=237823&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)
+++ llvm/trunk/lib/MC/MCDwarf.cpp Wed May 20 14:12:14 2015
@@ -360,8 +360,10 @@ unsigned MCDwarfLineTableHeader::getFile
     FileNumber = SourceIdMap.size() + 1;
     assert((MCDwarfFiles.empty() || FileNumber == MCDwarfFiles.size()) &&
            "Don't mix autonumbered and explicit numbered line table usage");
+    SmallString<256> Buffer;
     auto IterBool = SourceIdMap.insert(
-        std::make_pair((Directory + Twine('\0') + FileName).str(), FileNumber));
+        std::make_pair((Directory + Twine('\0') + FileName).toStringRef(Buffer),
+                       FileNumber));
     if (!IterBool.second)
       return IterBool.first->second;
   }





More information about the llvm-commits mailing list