[llvm-commits] new .file directive

Devang Patel dpatel at apple.com
Mon Oct 17 14:00:00 PDT 2011


On Oct 14, 2011, at 7:10 PM, Nick Lewycky wrote:

> 
> Please review!

> 
> Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> ===================================================================
> --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp	(revision 142035)
> +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp	(working copy)
> @@ -442,23 +442,21 @@
>    if (FileName.empty())
>      return GetOrCreateSourceID("<stdin>", 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());
> -  }
> +  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);
>  
> -  StringMapEntry<unsigned> &Entry = SourceIdMap.GetOrCreateValue(FileName);
> -  if (Entry.getValue())
> -    return Entry.getValue();
> +  std::map<std::pair<std::string, std::string>, unsigned>::iterator I;
> +  bool NewlyInserted;
> +  tie(I, NewlyInserted) = SourceIdMap.insert(Entry);
> +  if (!NewlyInserted)
> +    return I->second;
>  
> -  unsigned SrcId = SourceIdMap.size();
> -  Entry.setValue(SrcId);
> -
>    // 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;
>  }
> Index: lib/CodeGen/AsmPrinter/DwarfDebug.h
> ===================================================================
> --- lib/CodeGen/AsmPrinter/DwarfDebug.h	(revision 142035)
> +++ lib/CodeGen/AsmPrinter/DwarfDebug.h	(working copy)
> @@ -26,6 +26,7 @@
>  #include "llvm/ADT/UniqueVector.h"
>  #include "llvm/Support/Allocator.h"
>  #include "llvm/Support/DebugLoc.h"
> +#include <map>
>  
>  namespace llvm {
>  
> @@ -207,9 +208,9 @@
>    ///
>    std::vector<DIEAbbrev *> Abbreviations;
>  
> -  /// SourceIdMap - Source id map, i.e. pair of directory id and source file
> -  /// id mapped to a unique id.
> -  StringMap<unsigned> SourceIdMap;
> +  /// 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;
>  
>    /// StringPool - A String->Symbol mapping of strings used by indirect
>    /// references.

Why do you need this change in DwarfDebug ? Why can't MCAsmStreamer split file and directly ?
-
Devang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111017/54a76e32/attachment.html>


More information about the llvm-commits mailing list