[llvm-commits] [llvm] r152541 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h
Benjamin Kramer
benny.kra at googlemail.com
Sun Mar 11 07:56:26 PDT 2012
Author: d0k
Date: Sun Mar 11 09:56:26 2012
New Revision: 152541
URL: http://llvm.org/viewvc/llvm-project?rev=152541&view=rev
Log:
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.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=152541&r1=152540&r2=152541&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sun Mar 11 09:56:26 2012
@@ -523,20 +523,19 @@
DirName = "";
unsigned SrcId = SourceIdMap.size()+1;
- std::pair<std::string, std::string> SourceName =
- std::make_pair(FileName, DirName);
- std::pair<std::pair<std::string, std::string>, unsigned> Entry =
- make_pair(SourceName, SrcId);
-
- std::map<std::pair<std::string, std::string>, 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<unsigned> &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;
}
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=152541&r1=152540&r2=152541&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Sun Mar 11 09:56:26 2012
@@ -26,7 +26,6 @@
#include "llvm/ADT/UniqueVector.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/DebugLoc.h"
-#include <map>
namespace llvm {
@@ -209,9 +208,9 @@
///
std::vector<DIEAbbrev *> Abbreviations;
- /// SourceIdMap - Source id map, i.e. pair of source filename and directory
- /// mapped to a unique id.
- std::map<std::pair<std::string, std::string>, 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<unsigned> SourceIdMap;
/// StringPool - A String->Symbol mapping of strings used by indirect
/// references.
More information about the llvm-commits
mailing list