From bed96c8d97e72a3773606b714bb42037b6cf9a6b Mon Sep 17 00:00:00 2001 From: Pete Cooper Date: Wed, 20 May 2015 19:12:14 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237823 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCDwarf.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp index 05c2a02a8ed..74eee83b73f 100644 --- a/lib/MC/MCDwarf.cpp +++ b/lib/MC/MCDwarf.cpp @@ -360,8 +360,10 @@ unsigned MCDwarfLineTableHeader::getFile(StringRef &Directory, 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; } -- 2.34.1