From: Benjamin Kramer Date: Sun, 11 Mar 2012 14:56:26 +0000 (+0000) Subject: DwarfDebug: Store the filename/dirname pair as a zero-separated string in a stringmap... X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=74612c250bac1f62a2b74c85411cf7180cd8cd78;p=oota-llvm.git DwarfDebug: Store the filename/dirname pair as a zero-separated string in a stringmap, instead of using a highly inefficient std::map of a pair of std::strings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152541 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index fa62169b0b7..388cef4d8b8 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -523,20 +523,19 @@ unsigned DwarfDebug::GetOrCreateSourceID(StringRef FileName, DirName = ""; unsigned SrcId = SourceIdMap.size()+1; - std::pair SourceName = - std::make_pair(FileName, DirName); - std::pair, unsigned> Entry = - make_pair(SourceName, SrcId); - std::map, unsigned>::iterator I; - bool NewlyInserted; - llvm::tie(I, NewlyInserted) = SourceIdMap.insert(Entry); - if (!NewlyInserted) - return I->second; + // We look up the file/dir pair by concatenating them with a zero byte. + SmallString<128> NamePair; + NamePair += DirName; + NamePair += '\0'; // Zero bytes are not allowed in paths. + NamePair += FileName; + + StringMapEntry &Ent = SourceIdMap.GetOrCreateValue(NamePair, SrcId); + if (Ent.getValue() != SrcId) + return Ent.getValue(); // Print out a .file directive to specify files for .loc directives. - Asm->OutStreamer.EmitDwarfFileDirective(SrcId, Entry.first.second, - Entry.first.first); + Asm->OutStreamer.EmitDwarfFileDirective(SrcId, DirName, FileName); return SrcId; } diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index 8b802d2e21b..83f30f5b446 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -26,7 +26,6 @@ #include "llvm/ADT/UniqueVector.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/DebugLoc.h" -#include namespace llvm { @@ -209,9 +208,9 @@ class DwarfDebug { /// std::vector Abbreviations; - /// SourceIdMap - Source id map, i.e. pair of source filename and directory - /// mapped to a unique id. - std::map, unsigned> SourceIdMap; + /// SourceIdMap - Source id map, i.e. pair of source filename and directory, + /// separated by a zero byte, mapped to a unique id. + StringMap SourceIdMap; /// StringPool - A String->Symbol mapping of strings used by indirect /// references.