From 44d798d9763bc32aaf49fe7c10d604845f4b6685 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Mon, 17 Oct 2011 23:05:28 +0000 Subject: Add support for a new extension to the .file directive: .file filenumber "directory" "filename" This removes one join+split of the directory+filename in MC internals. Because bitcode files have independent fields for directory and filenames in debug info, this patch may change the .o files written by existing .bc files. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142300 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 28 +++++++++++++--------------- lib/CodeGen/AsmPrinter/DwarfDebug.h | 7 ++++--- lib/CodeGen/LLVMTargetMachine.cpp | 1 + 3 files changed, 18 insertions(+), 18 deletions(-) (limited to 'lib/CodeGen') diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 1b7e370fca..9978c829ba 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -442,23 +442,21 @@ unsigned DwarfDebug::GetOrCreateSourceID(StringRef FileName, if (FileName.empty()) return GetOrCreateSourceID("", StringRef()); - // MCStream expects full path name as filename. - if (!DirName.empty() && !sys::path::is_absolute(FileName)) { - SmallString<128> FullPathName = DirName; - sys::path::append(FullPathName, FileName); - // Here FullPathName will be copied into StringMap by GetOrCreateSourceID. - return GetOrCreateSourceID(StringRef(FullPathName), StringRef()); - } - - StringMapEntry &Entry = SourceIdMap.GetOrCreateValue(FileName); - if (Entry.getValue()) - return Entry.getValue(); - - unsigned SrcId = SourceIdMap.size(); - Entry.setValue(SrcId); + 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; + tie(I, NewlyInserted) = SourceIdMap.insert(Entry); + if (!NewlyInserted) + return I->second; // Print out a .file directive to specify files for .loc directives. - Asm->OutStreamer.EmitDwarfFileDirective(SrcId, Entry.getKey()); + Asm->OutStreamer.EmitDwarfFileDirective(SrcId, Entry.first.second, + Entry.first.first); return SrcId; } diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index 35653be5c8..faa78f3e48 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -26,6 +26,7 @@ #include "llvm/ADT/UniqueVector.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/DebugLoc.h" +#include namespace llvm { @@ -207,9 +208,9 @@ class DwarfDebug { /// std::vector Abbreviations; - /// SourceIdMap - Source id map, i.e. pair of directory id and source file - /// id mapped to a unique id. - StringMap SourceIdMap; + /// SourceIdMap - Source id map, i.e. pair of source filename and directory + /// mapped to a unique id. + std::map, unsigned> SourceIdMap; /// StringPool - A String->Symbol mapping of strings used by indirect /// references. diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp index 80ecc22481..759610a082 100644 --- a/lib/CodeGen/LLVMTargetMachine.cpp +++ b/lib/CodeGen/LLVMTargetMachine.cpp @@ -159,6 +159,7 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM, getVerboseAsm(), hasMCUseLoc(), hasMCUseCFI(), + hasMCUseDwarfDirectory(), InstPrinter, MCE, MAB, ShowMCInst); -- cgit v1.2.3