Index: docs/AMDGPUUsage.rst =================================================================== --- docs/AMDGPUUsage.rst +++ docs/AMDGPUUsage.rst @@ -780,7 +780,7 @@ DWARF ----- -Standard DWARF [DWARF]_ Version 2 sections can be generated. These contain +Standard DWARF [DWARF]_ Version 5 sections can be generated. These contain information that maps the code object executable code and data to the source language constructs. It can be used by tools such as debuggers and profilers. @@ -836,10 +836,60 @@ Source Text ~~~~~~~~~~~ -*This section is WIP.* +Source text for online-compiled programs (e.g. those compiled by the OpenCL +runtime) may be embedded into the DWARF v5 line table using the ``clang +-gembed-source`` option, described in table :ref:`amdgpu-debug-options`. -.. TODO - DWARF extension to include runtime generated source text. +For example: + +``-gembed-source`` + Enable the embedded source DWARF v5 extension. +``-gno-embed-source`` + Disable the embedded source DWARF v5 extension. + + .. table:: AMDGPU Debug Options + :name: amdgpu-debug-options + + ==================== ================================================== + Debug Flag Description + ==================== ================================================== + -g[no-]embed-source Enable/disable embedding source text in DWARF + debug sections. Useful for environments where + source cannot be written to disk, such as + when performing online compilation. + ==================== ================================================== + +This option enables one extended content types in the DWARF v5 Line Number +Program Header, which is used to encode embedded source. + + .. table:: AMDGPU DWARF Line Number Program Header Extended Content Types + :name: amdgpu-dwarf-extended-content-types + + ============================ ====================== + Content Type Form + ============================ ====================== + ``DW_LNCT_LLVM_source`` ``DW_FORM_line_strp`` + ============================ ====================== + +The source field will contain the UTF-8 encoded, null-terminated source text +with ``'\n'`` line endings. When the source field is present, consumers can use +the embedded source instead of attempting to discover the source on disk. When +the source field is absent, consumers can access the file to get the source +text. + +The above content type appears in the ``file_name_entry_format`` field of the +line table prologue, and its corresponding value appear in the ``file_names`` +field. The current encoding of the content type is documented in table +:ref:`amdgpu-dwarf-extended-content-types-encoding` + + .. table:: AMDGPU DWARF Line Number Program Header Extended Content Types Encoding + :name: amdgpu-dwarf-extended-content-types-encoding + + ============================ ==================== + Content Type Value + ============================ ==================== + ``DW_LNCT_LLVM_source`` 0x2001 + ============================ ==================== .. _amdgpu-code-conventions: Index: include/llvm/BinaryFormat/Dwarf.def =================================================================== --- include/llvm/BinaryFormat/Dwarf.def +++ include/llvm/BinaryFormat/Dwarf.def @@ -747,6 +747,9 @@ HANDLE_DW_LNCT(0x03, timestamp) HANDLE_DW_LNCT(0x04, size) HANDLE_DW_LNCT(0x05, MD5) +// A vendor extension until http://dwarfstd.org/ShowIssue.php?issue=180201.1 is +// accepted and incorporated into the next DWARF standard. +HANDLE_DW_LNCT(0x2001, LLVM_source) // DWARF v5 Macro information. HANDLE_DW_MACRO(0x01, define) Index: include/llvm/DebugInfo/DIContext.h =================================================================== --- include/llvm/DebugInfo/DIContext.h +++ include/llvm/DebugInfo/DIContext.h @@ -31,6 +31,7 @@ struct DILineInfo { std::string FileName; std::string FunctionName; + Optional Source; uint32_t Line = 0; uint32_t Column = 0; uint32_t StartLine = 0; Index: include/llvm/DebugInfo/DWARF/DWARFDebugLine.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDebugLine.h +++ include/llvm/DebugInfo/DWARF/DWARFDebugLine.h @@ -10,6 +10,7 @@ #ifndef LLVM_DEBUGINFO_DWARFDEBUGLINE_H #define LLVM_DEBUGINFO_DWARFDEBUGLINE_H +#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" @@ -36,6 +37,25 @@ uint64_t ModTime = 0; uint64_t Length = 0; MD5::MD5Result Checksum; + DWARFFormValue Source; + }; + + /// Tracks which optional content types are present in a DWARF file name + /// entry format. + struct ContentTypeTracker { + ContentTypeTracker() = default; + + /// Whether filename entries provide a modification timestamp. + bool HasModTime = false; + /// Whether filename entries provide a file size. + bool HasLength = false; + /// For v5, whether filename entries provide an MD5 checksum. + bool HasMD5 = false; + /// For v5, whether filename entries provide source text. + bool HasSource = false; + + /// Update tracked content types with \p ContentType. + void trackContentType(dwarf::LineNumberEntryFormat ContentType); }; struct Prologue { @@ -68,8 +88,8 @@ uint8_t LineRange; /// The number assigned to the first special opcode. uint8_t OpcodeBase; - /// For v5, whether filename entries provide an MD5 checksum. - bool HasMD5; + /// This tracks which optional file format content types are present. + ContentTypeTracker ContentTypes; std::vector StandardOpcodeLengths; std::vector IncludeDirectories; std::vector FileNames; @@ -239,6 +259,8 @@ private: uint32_t findRowInSeq(const DWARFDebugLine::Sequence &Seq, uint64_t Address) const; + Optional getSourceByIndex(uint64_t FileIndex, + DILineInfoSpecifier::FileLineInfoKind Kind) const; }; const LineTable *getLineTable(uint32_t Offset) const; Index: include/llvm/IR/DIBuilder.h =================================================================== --- include/llvm/IR/DIBuilder.h +++ include/llvm/IR/DIBuilder.h @@ -19,6 +19,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" @@ -141,10 +142,13 @@ /// Create a file descriptor to hold debugging information for a file. /// \param Filename File name. /// \param Directory Directory. - /// \param Checksum Checksum kind (e.g. CSK_MD5, CSK_SHA1, etc.) and value. + /// \param Checksum Optional checksum kind (e.g. CSK_MD5, CSK_SHA1, etc.) + /// and value. + /// \param Source Optional source text. DIFile * createFile(StringRef Filename, StringRef Directory, - Optional> Checksum = None); + Optional> Checksum = None, + Optional Source = None); /// Create debugging information entry for a macro. /// \param Parent Macro parent (could be nullptr). Index: include/llvm/IR/DebugInfoMetadata.h =================================================================== --- include/llvm/IR/DebugInfoMetadata.h +++ include/llvm/IR/DebugInfoMetadata.h @@ -455,6 +455,7 @@ inline StringRef getFilename() const; inline StringRef getDirectory() const; + inline Optional getSource() const; StringRef getName() const; DIScopeRef getScope() const; @@ -532,42 +533,48 @@ private: Optional> Checksum; + Optional Source; DIFile(LLVMContext &C, StorageType Storage, - Optional> CS, + Optional> CS, Optional Src, ArrayRef Ops) : DIScope(C, DIFileKind, Storage, dwarf::DW_TAG_file_type, Ops), - Checksum(CS) {} + Checksum(CS), Source(Src) {} ~DIFile() = default; static DIFile *getImpl(LLVMContext &Context, StringRef Filename, StringRef Directory, Optional> CS, + Optional Source, StorageType Storage, bool ShouldCreate = true) { Optional> MDChecksum; if (CS) MDChecksum.emplace(CS->Kind, getCanonicalMDString(Context, CS->Value)); return getImpl(Context, getCanonicalMDString(Context, Filename), getCanonicalMDString(Context, Directory), MDChecksum, + Source ? Optional(getCanonicalMDString(Context, *Source)) : None, Storage, ShouldCreate); } static DIFile *getImpl(LLVMContext &Context, MDString *Filename, MDString *Directory, Optional> CS, - StorageType Storage, bool ShouldCreate = true); + Optional Source, StorageType Storage, + bool ShouldCreate = true); TempDIFile cloneImpl() const { return getTemporary(getContext(), getFilename(), getDirectory(), - getChecksum()); + getChecksum(), getSource()); } public: DEFINE_MDNODE_GET(DIFile, (StringRef Filename, StringRef Directory, - Optional> CS = None), - (Filename, Directory, CS)) + Optional> CS = None, + Optional Source = None), + (Filename, Directory, CS, Source)) DEFINE_MDNODE_GET(DIFile, (MDString * Filename, MDString *Directory, - Optional> CS = None), - (Filename, Directory, CS)) + Optional> CS = None, + Optional Source = None), + (Filename, Directory, CS, Source)) TempDIFile clone() const { return cloneImpl(); } @@ -579,10 +586,14 @@ StringRefChecksum.emplace(Checksum->Kind, Checksum->Value->getString()); return StringRefChecksum; } + Optional getSource() const { + return Source ? Optional((*Source)->getString()) : None; + } MDString *getRawFilename() const { return getOperandAs(0); } MDString *getRawDirectory() const { return getOperandAs(1); } Optional> getRawChecksum() const { return Checksum; } + Optional getRawSource() const { return Source; } static StringRef getChecksumKindAsString(ChecksumKind CSKind); static Optional getChecksumKind(StringRef CSKindStr); @@ -604,6 +615,12 @@ return ""; } +Optional DIScope::getSource() const { + if (auto *F = getFile()) + return F->getSource(); + return None; +} + /// Base class for types. /// /// TODO: Remove the hardcoded name and context, since many types don't use @@ -1408,6 +1425,7 @@ DIFile *getFile() const { return getScope()->getFile(); } StringRef getFilename() const { return getScope()->getFilename(); } StringRef getDirectory() const { return getScope()->getDirectory(); } + Optional getSource() const { return getScope()->getSource(); } /// Get the scope where this is inlined. /// @@ -2177,6 +2195,12 @@ return ""; } + Optional getSource() const { + if (auto *F = getFile()) + return F->getSource(); + return None; + } + Metadata *getRawScope() const { return getOperand(0); } MDString *getRawName() const { return getOperandAs(1); } Metadata *getRawFile() const { return getOperand(2); } @@ -2624,6 +2648,12 @@ return ""; } + Optional getSource() const { + if (auto *F = getFile()) + return F->getSource(); + return None; + } + MDString *getRawName() const { return getOperandAs(0); } Metadata *getRawFile() const { return getOperand(1); } MDString *getRawGetterName() const { return getOperandAs(2); } Index: include/llvm/MC/MCContext.h =================================================================== --- include/llvm/MC/MCContext.h +++ include/llvm/MC/MCContext.h @@ -11,6 +11,7 @@ #define LLVM_MC_MCCONTEXT_H #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" @@ -495,7 +496,7 @@ /// Creates an entry in the dwarf file and directory tables. unsigned getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, MD5::MD5Result *Checksum, - unsigned CUID); + Optional Source, unsigned CUID); bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID = 0); Index: include/llvm/MC/MCDwarf.h =================================================================== --- include/llvm/MC/MCDwarf.h +++ include/llvm/MC/MCDwarf.h @@ -16,6 +16,7 @@ #define LLVM_MC_MCDWARF_H #include "llvm/ADT/MapVector.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" @@ -47,7 +48,6 @@ /// index 0 is not used and not a valid dwarf file number). struct MCDwarfFile { // \brief The base name of the file without its directory path. - // The StringRef references memory allocated in the MCContext. std::string Name; // \brief The index into the list of directory names for this file name. @@ -56,6 +56,10 @@ /// The MD5 checksum, if there is one. Non-owning pointer to data allocated /// in MCContext. MD5::MD5Result *Checksum = nullptr; + + // \brief The source code of the file. Non-owning reference to data allocated + // in MCContext. + Optional Source; }; /// \brief Instances of this class represent the information from a @@ -210,11 +214,15 @@ StringMap SourceIdMap; StringRef CompilationDir; bool HasMD5 = false; + bool HasSource = false; MCDwarfLineTableHeader() = default; unsigned getFile(StringRef &Directory, StringRef &FileName, - MD5::MD5Result *Checksum, unsigned FileNumber = 0); + MD5::MD5Result *Checksum, Optional &Source, + unsigned FileNumber = 0); + std::pair Emit(MCStreamer *MCOS, + MCDwarfLineTableParams Params) const; std::pair Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, Optional &LineStr) const; @@ -238,8 +246,8 @@ } unsigned getFile(StringRef Directory, StringRef FileName, - MD5::MD5Result *Checksum) { - return Header.getFile(Directory, FileName, Checksum); + MD5::MD5Result *Checksum, Optional Source) { + return Header.getFile(Directory, FileName, Checksum, Source); } void Emit(MCStreamer &MCOS, MCDwarfLineTableParams Params) const; @@ -258,7 +266,8 @@ Optional &LineStr) const; unsigned getFile(StringRef &Directory, StringRef &FileName, - MD5::MD5Result *Checksum, unsigned FileNumber = 0); + MD5::MD5Result *Checksum, Optional &Source, + unsigned FileNumber = 0); MCSymbol *getLabel() const { return Header.Label; Index: include/llvm/MC/MCStreamer.h =================================================================== --- include/llvm/MC/MCStreamer.h +++ include/llvm/MC/MCStreamer.h @@ -16,6 +16,8 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/MC/MCDirectives.h" @@ -750,11 +752,15 @@ /// '.ident "version foo"' assembler directive. virtual void EmitIdent(StringRef IdentString) {} - /// \brief Associate a filename with a specified logical file number. This - /// implements the DWARF2 '.file 4 "foo.c"' assembler directive. + /// \brief Associate a filename with a specified logical file number. + /// Also associate a directory, optional checksum, and optional source + /// text with the logical file. This implements the DWARF2 + /// '.file 4 "dir/foo.c"' assembler directive, and the DWARF5 + /// '.file 4 "dir/foo.c" md5 "..." source "..."' assembler directive. virtual unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, MD5::MD5Result *Checksum = nullptr, + Optional Source = None, unsigned CUID = 0); /// \brief This implements the DWARF2 '.loc fileno lineno ...' assembler Index: lib/AsmParser/LLParser.cpp =================================================================== --- lib/AsmParser/LLParser.cpp +++ lib/AsmParser/LLParser.cpp @@ -4243,9 +4243,10 @@ } /// ParseDIFileType: -/// ::= !DIFileType(filename: "path/to/file", directory: "/path/to/dir" +/// ::= !DIFileType(filename: "path/to/file", directory: "/path/to/dir", /// checksumkind: CSK_MD5, -/// checksum: "000102030405060708090a0b0c0d0e0f") +/// checksum: "000102030405060708090a0b0c0d0e0f", +/// source: "source file contents") bool LLParser::ParseDIFile(MDNode *&Result, bool IsDistinct) { // The default constructed value for checksumkind is required, but will never // be used, as the parser checks if the field was actually Seen before using @@ -4254,7 +4255,8 @@ REQUIRED(filename, MDStringField, ); \ REQUIRED(directory, MDStringField, ); \ OPTIONAL(checksumkind, ChecksumKindField, (DIFile::CSK_MD5)); \ - OPTIONAL(checksum, MDStringField, ); + OPTIONAL(checksum, MDStringField, ); \ + OPTIONAL(source, MDStringField, ); PARSE_MD_FIELDS(); #undef VISIT_MD_FIELDS @@ -4264,8 +4266,11 @@ else if (checksumkind.Seen || checksum.Seen) return Lex.Error("'checksumkind' and 'checksum' must be provided together"); + Optional OptSource; + if (source.Seen) + OptSource = source.Val; Result = GET_OR_DISTINCT(DIFile, (Context, filename.Val, directory.Val, - OptChecksum)); + OptChecksum, OptSource)); return false; } Index: lib/Bitcode/Reader/MetadataLoader.cpp =================================================================== --- lib/Bitcode/Reader/MetadataLoader.cpp +++ lib/Bitcode/Reader/MetadataLoader.cpp @@ -1350,7 +1350,7 @@ } case bitc::METADATA_FILE: { - if (Record.size() != 3 && Record.size() != 5) + if (Record.size() < 3 || Record.size() > 6) return error("Invalid record"); IsDistinct = Record[0]; @@ -1360,14 +1360,15 @@ // and the old encoding for CSK_None in the ChecksumKind. The new // representation reserves the value 0 in the ChecksumKind to continue to // encode None in a backwards-compatible way. - if (Record.size() == 5 && Record[3] && Record[4]) + if (Record.size() > 4 && Record[3] && Record[4]) Checksum.emplace(static_cast(Record[3]), getMDString(Record[4])); MetadataList.assignValue( GET_OR_DISTINCT( DIFile, - (Context, getMDString(Record[1]), getMDString(Record[2]), - Checksum)), + (Context, getMDString(Record[1]), getMDString(Record[2]), Checksum, + Record.size() > 5 ? Optional(getMDString(Record[5])) + : None)), NextMetadataNo); NextMetadataNo++; break; Index: lib/Bitcode/Writer/BitcodeWriter.cpp =================================================================== --- lib/Bitcode/Writer/BitcodeWriter.cpp +++ lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1560,6 +1560,9 @@ Record.push_back(0); Record.push_back(VE.getMetadataOrNullID(nullptr)); } + auto Source = N->getRawSource(); + if (Source) + Record.push_back(VE.getMetadataOrNullID(*Source)); Stream.EmitRecord(bitc::METADATA_FILE, Record, Abbrev); Record.clear(); Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -102,9 +102,10 @@ // extend .file to support this. unsigned CUID = Asm->OutStreamer->hasRawTextSupport() ? 0 : getUniqueID(); if (!File) - return Asm->OutStreamer->EmitDwarfFileDirective(0, "", "", nullptr, CUID); + return Asm->OutStreamer->EmitDwarfFileDirective(0, "", "", nullptr, None, CUID); return Asm->OutStreamer->EmitDwarfFileDirective( - 0, File->getDirectory(), File->getFilename(), getMD5AsBytes(File), CUID); + 0, File->getDirectory(), File->getFilename(), getMD5AsBytes(File), + File->getSource(), CUID); } DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE( Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1384,7 +1384,7 @@ void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S, unsigned Flags) { StringRef Fn; - unsigned Src = 1; + unsigned FileNo = 1; unsigned Discriminator = 0; if (auto *Scope = cast_or_null(S)) { Fn = Scope->getFilename(); @@ -1393,10 +1393,10 @@ Discriminator = LBF->getDiscriminator(); unsigned CUID = Asm->OutStreamer->getContext().getDwarfCompileUnitID(); - Src = static_cast(*InfoHolder.getUnits()[CUID]) + FileNo = static_cast(*InfoHolder.getUnits()[CUID]) .getOrCreateSourceID(Scope->getFile()); } - Asm->OutStreamer->EmitDwarfLocDirective(Src, Line, Col, Flags, 0, + Asm->OutStreamer->EmitDwarfLocDirective(FileNo, Line, Col, Flags, 0, Discriminator, Fn); } Index: lib/CodeGen/AsmPrinter/DwarfUnit.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -302,7 +302,9 @@ unsigned DwarfTypeUnit::getOrCreateSourceID(const DIFile *File) { return SplitLineTable ? SplitLineTable->getFile(File->getDirectory(), - File->getFilename(), getMD5AsBytes(File)) + File->getFilename(), + getMD5AsBytes(File), + File->getSource()) : getCU().getOrCreateSourceID(File); } Index: lib/DebugInfo/DWARF/DWARFContext.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFContext.cpp +++ lib/DebugInfo/DWARF/DWARFContext.cpp @@ -466,7 +466,9 @@ uint32_t offset = 0; uint32_t strOffset = 0; while (const char *s = strData.getCStr(&offset)) { - OS << format("0x%8.8x: \"%s\"\n", strOffset, s); + OS << format("0x%8.8x: \"", strOffset); + OS.write_escaped(s); + OS << "\"\n"; strOffset = offset; } } Index: lib/DebugInfo/DWARF/DWARFDebugLine.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -8,6 +8,8 @@ //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" @@ -40,6 +42,28 @@ } // end anonmyous namespace +void DWARFDebugLine::ContentTypeTracker::trackContentType( + dwarf::LineNumberEntryFormat ContentType) { + switch (ContentType) { + case dwarf::DW_LNCT_timestamp: + HasModTime = true; + break; + case dwarf::DW_LNCT_size: + HasLength = true; + break; + case dwarf::DW_LNCT_MD5: + HasMD5 = true; + break; + case dwarf::DW_LNCT_LLVM_source: + HasSource = true; + break; + default: + // We only care about values we consider optional, and new values may be + // added in the vendor extension range, so we do not match exhaustively. + break; + } +} + DWARFDebugLine::Prologue::Prologue() { clear(); } void DWARFDebugLine::Prologue::clear() { @@ -48,7 +72,7 @@ MinInstLength = MaxOpsPerInst = DefaultIsStmt = LineBase = LineRange = 0; OpcodeBase = 0; FormParams = DWARFFormParams({0, 0, DWARF32}); - HasMD5 = false; + ContentTypes = ContentTypeTracker(); StandardOpcodeLengths.clear(); IncludeDirectories.clear(); FileNames.clear(); @@ -85,28 +109,26 @@ } if (!FileNames.empty()) { - if (HasMD5) - OS << " Dir MD5 Checksum File Name\n" - << " ---- -------------------------------- -----------" - "---------------\n"; - else - OS << " Dir Mod Time File Len File Name\n" - << " ---- ---------- ---------- -----------" - "----------------\n"; // DWARF v5 starts file indexes at 0. uint32_t FileBase = getVersion() >= 5 ? 0 : 1; for (uint32_t I = 0; I != FileNames.size(); ++I) { const FileNameEntry &FileEntry = FileNames[I]; - OS << format("file_names[%3u] %4" PRIu64 " ", I + FileBase, - FileEntry.DirIdx); - if (HasMD5) - OS << FileEntry.Checksum.digest(); - else - OS << format("0x%8.8" PRIx64 " 0x%8.8" PRIx64, FileEntry.ModTime, - FileEntry.Length); - OS << ' '; + OS << format("file_names[%3u]:\n", I + FileBase); + OS << " name: "; FileEntry.Name.dump(OS, DumpOptions); - OS << '\n'; + OS << '\n' + << format(" dir_index: %" PRIu64 "\n", FileEntry.DirIdx); + if (ContentTypes.HasMD5) + OS << " md5_checksum: " << FileEntry.Checksum.digest() << '\n'; + if (ContentTypes.HasModTime) + OS << format(" mod_time: 0x%8.8" PRIx64 "\n", FileEntry.ModTime); + if (ContentTypes.HasLength) + OS << format(" length: 0x%8.8" PRIx64 "\n", FileEntry.Length); + if (ContentTypes.HasSource) { + OS << " source: "; + FileEntry.Source.dump(OS, DumpOptions); + OS << '\n'; + } } } } @@ -115,6 +137,7 @@ static void parseV2DirFileTables(const DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr, uint64_t EndPrologueOffset, + DWARFDebugLine::ContentTypeTracker &ContentTypes, std::vector &IncludeDirectories, std::vector &FileNames) { while (*OffsetPtr < EndPrologueOffset) { @@ -138,14 +161,18 @@ FileEntry.Length = DebugLineData.getULEB128(OffsetPtr); FileNames.push_back(FileEntry); } + + ContentTypes.HasModTime = true; + ContentTypes.HasLength = true; } // Parse v5 directory/file entry content descriptions. // Returns the descriptors, or an empty vector if we did not find a path or // ran off the end of the prologue. static ContentDescriptors -parseV5EntryFormat(const DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr, - uint64_t EndPrologueOffset, bool *HasMD5) { +parseV5EntryFormat(const DWARFDataExtractor &DebugLineData, uint32_t + *OffsetPtr, uint64_t EndPrologueOffset, DWARFDebugLine::ContentTypeTracker + *ContentTypes) { ContentDescriptors Descriptors; int FormatCount = DebugLineData.getU8(OffsetPtr); bool HasPath = false; @@ -158,8 +185,8 @@ Descriptor.Form = dwarf::Form(DebugLineData.getULEB128(OffsetPtr)); if (Descriptor.Type == dwarf::DW_LNCT_path) HasPath = true; - else if (Descriptor.Type == dwarf::DW_LNCT_MD5 && HasMD5) - *HasMD5 = true; + if (ContentTypes) + ContentTypes->trackContentType(Descriptor.Type); Descriptors.push_back(Descriptor); } return HasPath ? Descriptors : ContentDescriptors(); @@ -168,8 +195,9 @@ static bool parseV5DirFileTables(const DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr, uint64_t EndPrologueOffset, - const DWARFFormParams &FormParams, const DWARFContext &Ctx, - const DWARFUnit *U, bool &HasMD5, + const DWARFFormParams &FormParams, const DWARFContext + &Ctx, const DWARFUnit *U, + DWARFDebugLine::ContentTypeTracker &ContentTypes, std::vector &IncludeDirectories, std::vector &FileNames) { // Get the directory entry description. @@ -200,7 +228,8 @@ // Get the file entry description. ContentDescriptors FileDescriptors = - parseV5EntryFormat(DebugLineData, OffsetPtr, EndPrologueOffset, &HasMD5); + parseV5EntryFormat(DebugLineData, OffsetPtr, EndPrologueOffset, + &ContentTypes); if (FileDescriptors.empty()) return false; @@ -218,6 +247,9 @@ case DW_LNCT_path: FileEntry.Name = Value; break; + case DW_LNCT_LLVM_source: + FileEntry.Source = Value; + break; case DW_LNCT_directory_index: FileEntry.DirIdx = Value.getAsUnsignedConstant().getValue(); break; @@ -285,8 +317,8 @@ if (getVersion() >= 5) { if (!parseV5DirFileTables(DebugLineData, OffsetPtr, EndPrologueOffset, - FormParams, Ctx, U, HasMD5, IncludeDirectories, - FileNames)) { + FormParams, Ctx, U, ContentTypes, + IncludeDirectories, FileNames)) { fprintf(stderr, "warning: parsing line table prologue at 0x%8.8" PRIx64 " found an invalid directory or file table description at" @@ -295,7 +327,7 @@ } } else parseV2DirFileTables(DebugLineData, OffsetPtr, EndPrologueOffset, - IncludeDirectories, FileNames); + ContentTypes, IncludeDirectories, FileNames); if (*OffsetPtr != EndPrologueOffset) { fprintf(stderr, @@ -912,6 +944,16 @@ return FileIndex != 0 && FileIndex <= Prologue.FileNames.size(); } +Optional DWARFDebugLine::LineTable::getSourceByIndex(uint64_t FileIndex, + FileLineInfoKind Kind) const { + if (Kind == FileLineInfoKind::None || !hasFileAtIndex(FileIndex)) + return None; + const FileNameEntry &Entry = Prologue.FileNames[FileIndex - 1]; + if (Optional source = Entry.Source.getAsCString()) + return StringRef(*source); + return None; +} + bool DWARFDebugLine::LineTable::getFileNameByIndex(uint64_t FileIndex, const char *CompDir, FileLineInfoKind Kind, @@ -963,5 +1005,6 @@ Result.Line = Row.Line; Result.Column = Row.Column; Result.Discriminator = Row.Discriminator; + Result.Source = getSourceByIndex(Row.File, Kind); return true; } Index: lib/IR/AsmWriter.cpp =================================================================== --- lib/IR/AsmWriter.cpp +++ lib/IR/AsmWriter.cpp @@ -1723,6 +1723,8 @@ // Print all values for checksum together, or not at all. if (N->getChecksum()) Printer.printChecksum(*N->getChecksum()); + Printer.printString("source", N->getSource().getValueOr(StringRef()), + /* ShouldSkipEmpty */ true); Out << ")"; } Index: lib/IR/DIBuilder.cpp =================================================================== --- lib/IR/DIBuilder.cpp +++ lib/IR/DIBuilder.cpp @@ -14,6 +14,7 @@ #include "llvm/IR/DIBuilder.h" #include "llvm/IR/IRBuilder.h" #include "LLVMContextImpl.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/IR/Constants.h" @@ -204,8 +205,9 @@ } DIFile *DIBuilder::createFile(StringRef Filename, StringRef Directory, - Optional> CS) { - return DIFile::get(VMContext, Filename, Directory, CS); + Optional> CS, + Optional Source) { + return DIFile::get(VMContext, Filename, Directory, CS, Source); } DIMacro *DIBuilder::createMacro(DIMacroFile *Parent, unsigned LineNumber, Index: lib/IR/DebugInfo.cpp =================================================================== --- lib/IR/DebugInfo.cpp +++ lib/IR/DebugInfo.cpp @@ -16,6 +16,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" Index: lib/IR/DebugInfoMetadata.cpp =================================================================== --- lib/IR/DebugInfoMetadata.cpp +++ lib/IR/DebugInfoMetadata.cpp @@ -417,13 +417,16 @@ DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename, MDString *Directory, Optional> CS, - StorageType Storage, bool ShouldCreate) { + Optional Source, StorageType Storage, + bool ShouldCreate) { assert(isCanonical(Filename) && "Expected canonical MDString"); assert(isCanonical(Directory) && "Expected canonical MDString"); assert((!CS || isCanonical(CS->Value)) && "Expected canonical MDString"); - DEFINE_GETIMPL_LOOKUP(DIFile, (Filename, Directory, CS)); - Metadata *Ops[] = {Filename, Directory, CS ? CS->Value : nullptr}; - DEFINE_GETIMPL_STORE(DIFile, (CS), Ops); + assert((!Source || isCanonical(*Source)) && "Expected canonical MDString"); + DEFINE_GETIMPL_LOOKUP(DIFile, (Filename, Directory, CS, Source)); + Metadata *Ops[] = {Filename, Directory, CS ? CS->Value : nullptr, + Source.getValueOr(nullptr)}; + DEFINE_GETIMPL_STORE(DIFile, (CS, Source), Ops); } DICompileUnit *DICompileUnit::getImpl( Index: lib/IR/LLVMContextImpl.h =================================================================== --- lib/IR/LLVMContextImpl.h +++ lib/IR/LLVMContextImpl.h @@ -575,24 +575,28 @@ MDString *Filename; MDString *Directory; Optional> Checksum; + Optional Source; MDNodeKeyImpl(MDString *Filename, MDString *Directory, - Optional> Checksum) - : Filename(Filename), Directory(Directory), Checksum(Checksum) {} + Optional> Checksum, + Optional Source) + : Filename(Filename), Directory(Directory), Checksum(Checksum), + Source(Source) {} MDNodeKeyImpl(const DIFile *N) : Filename(N->getRawFilename()), Directory(N->getRawDirectory()), - Checksum(N->getRawChecksum()) {} + Checksum(N->getRawChecksum()), Source(N->getRawSource()) {} bool isKeyOf(const DIFile *RHS) const { return Filename == RHS->getRawFilename() && Directory == RHS->getRawDirectory() && - Checksum == RHS->getRawChecksum(); + Checksum == RHS->getRawChecksum() && + Source == RHS->getRawSource(); } unsigned getHashValue() const { - if (Checksum) - return hash_combine(Filename, Directory, Checksum->Kind, Checksum->Value); - return hash_combine(Filename, Directory); + return hash_combine( + Filename, Directory, Checksum ? Checksum->Kind : 0, + Checksum ? Checksum->Value : nullptr, Source.getValueOr(nullptr)); } }; Index: lib/MC/MCAsmStreamer.cpp =================================================================== --- lib/MC/MCAsmStreamer.cpp +++ lib/MC/MCAsmStreamer.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" @@ -214,6 +216,7 @@ unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, MD5::MD5Result *Checksum = 0, + Optional Source = None, unsigned CUID = 0) override; void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, @@ -1077,12 +1080,13 @@ StringRef Directory, StringRef Filename, MD5::MD5Result *Checksum, + Optional Source, unsigned CUID) { assert(CUID == 0); MCDwarfLineTable &Table = getContext().getMCDwarfLineTable(CUID); unsigned NumFiles = Table.getMCDwarfFiles().size(); - FileNo = Table.getFile(Directory, Filename, Checksum, FileNo); + FileNo = Table.getFile(Directory, Filename, Checksum, Source, FileNo); if (FileNo == 0) return 0; if (NumFiles == Table.getMCDwarfFiles().size()) @@ -1113,6 +1117,10 @@ OS1 << " md5 "; PrintQuotedString(Checksum->digest(), OS1); } + if (Source) { + OS1 << " source "; + PrintQuotedString(*Source, OS1); + } if (MCTargetStreamer *TS = getTargetStreamer()) { TS->emitDwarfFileDirective(OS1.str()); } else { Index: lib/MC/MCContext.cpp =================================================================== --- lib/MC/MCContext.cpp +++ lib/MC/MCContext.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCContext.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" @@ -532,15 +533,15 @@ // Dwarf Management //===----------------------------------------------------------------------===// -/// getDwarfFile - takes a file name an number to place in the dwarf file and +/// getDwarfFile - takes a file name and number to place in the dwarf file and /// directory tables. If the file number has already been allocated it is an /// error and zero is returned and the client reports the error, else the /// allocated file number is returned. The file numbers may be in any order. unsigned MCContext::getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, MD5::MD5Result *Checksum, - unsigned CUID) { + Optional Source, unsigned CUID) { MCDwarfLineTable &Table = MCDwarfLineTablesCUMap[CUID]; - return Table.getFile(Directory, FileName, Checksum, FileNumber); + return Table.getFile(Directory, FileName, Checksum, Source, FileNumber); } /// isValidDwarfFileNumber - takes a dwarf file number and returns true if it Index: lib/MC/MCDwarf.cpp =================================================================== --- lib/MC/MCDwarf.cpp +++ lib/MC/MCDwarf.cpp @@ -12,6 +12,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Hashing.h" #include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" @@ -373,8 +374,13 @@ // The file format, which is the inline null-terminated filename and a // directory index. We don't track file size/timestamp so don't emit them - // in the v5 table. Emit MD5 checksums if we have them. - MCOS->EmitIntValue(HasMD5 ? 3 : 2, 1); + // in the v5 table. Emit MD5 checksums and source if we have them. + uint64_t Entries = 2; + if (HasMD5) + Entries += 1; + if (HasSource) + Entries += 1; + MCOS->EmitIntValue(Entries, 1); MCOS->EmitULEB128IntValue(dwarf::DW_LNCT_path); MCOS->EmitULEB128IntValue(LineStr ? dwarf::DW_FORM_line_strp : dwarf::DW_FORM_string); @@ -384,6 +390,11 @@ MCOS->EmitULEB128IntValue(dwarf::DW_LNCT_MD5); MCOS->EmitULEB128IntValue(dwarf::DW_FORM_data16); } + if (HasSource) { + MCOS->EmitULEB128IntValue(dwarf::DW_LNCT_LLVM_source); + MCOS->EmitULEB128IntValue(LineStr ? dwarf::DW_FORM_line_strp + : dwarf::DW_FORM_string); + } // Then the list of file names. These start at 1. MCOS->EmitULEB128IntValue(MCDwarfFiles.size() - 1); for (unsigned i = 1; i < MCDwarfFiles.size(); ++i) { @@ -401,6 +412,15 @@ StringRef(reinterpret_cast(Cksum->Bytes.data()), Cksum->Bytes.size())); } + if (HasSource) { + if (LineStr) + LineStr->emitRef(MCOS, MCDwarfFiles[i].Source.getValueOr(StringRef())); + else { + MCOS->EmitBytes( + MCDwarfFiles[i].Source.getValueOr(StringRef())); // Source and... + MCOS->EmitBytes(StringRef("\0", 1)); // its null terminator. + } + } } } @@ -499,13 +519,15 @@ unsigned MCDwarfLineTable::getFile(StringRef &Directory, StringRef &FileName, MD5::MD5Result *Checksum, + Optional &Source, unsigned FileNumber) { - return Header.getFile(Directory, FileName, Checksum, FileNumber); + return Header.getFile(Directory, FileName, Checksum, Source, FileNumber); } unsigned MCDwarfLineTableHeader::getFile(StringRef &Directory, StringRef &FileName, MD5::MD5Result *Checksum, + Optional &Source, unsigned FileNumber) { if (Directory == CompilationDir) Directory = ""; @@ -536,9 +558,11 @@ if (!File.Name.empty()) return 0; - // If any files have an MD5 checksum, they all must. - if (FileNumber > 1) - assert(HasMD5 == (Checksum != nullptr)); + // If any files have an MD5 checksum or source text, they all must. + assert((FileNumber == 1 || HasMD5 == (Checksum != nullptr)) && + "Files mixed with and without MD5 checksum."); + assert((FileNumber == 1 || HasSource == (Source != None)) && + "Files mixed with and without embedded source text."); if (Directory.empty()) { // Separate the directory part from the basename of the FileName. @@ -576,6 +600,9 @@ File.Checksum = Checksum; if (Checksum) HasMD5 = true; + File.Source = Source; + if (Source) + HasSource = true; // return the allocated FileNumber. return FileNumber; Index: lib/MC/MCParser/AsmParser.cpp =================================================================== --- lib/MC/MCParser/AsmParser.cpp +++ lib/MC/MCParser/AsmParser.cpp @@ -3250,7 +3250,7 @@ /// parseDirectiveFile /// ::= .file filename -/// ::= .file number [directory] filename [md5 checksum] +/// ::= .file number [directory] filename [md5 checksum] [source source-text] bool AsmParser::parseDirectiveFile(SMLoc DirectiveLoc) { // FIXME: I'm not sure what this is. int64_t FileNumber = -1; @@ -3287,23 +3287,36 @@ } std::string Checksum; - if (!parseOptionalToken(AsmToken::EndOfStatement)) { + + Optional Source; + bool HasSource = false; + std::string SourceString; + + while (!parseOptionalToken(AsmToken::EndOfStatement)) { StringRef Keyword; if (check(getTok().isNot(AsmToken::Identifier), "unexpected token in '.file' directive") || - parseIdentifier(Keyword) || - check(Keyword != "md5", "unexpected token in '.file' directive")) - return true; - if (getLexer().is(AsmToken::String) && - check(FileNumber == -1, "MD5 checksum specified, but no file number")) - return true; - if (check(getTok().isNot(AsmToken::String), - "unexpected token in '.file' directive") || - parseEscapedString(Checksum) || - check(Checksum.size() != 32, "invalid MD5 checksum specified") || - parseToken(AsmToken::EndOfStatement, - "unexpected token in '.file' directive")) + parseIdentifier(Keyword)) return true; + if (Keyword == "md5") { + if (check(FileNumber == -1, + "MD5 checksum specified, but no file number") || + check(getTok().isNot(AsmToken::String), + "unexpected token in '.file' directive") || + parseEscapedString(Checksum) || + check(Checksum.size() != 32, "invalid MD5 checksum specified")) + return true; + } else if (Keyword == "source") { + HasSource = true; + if (check(FileNumber == -1, + "source specified, but no file number") || + check(getTok().isNot(AsmToken::String), + "unexpected token in '.file' directive") || + parseEscapedString(SourceString)) + return true; + } else { + return TokError("unexpected token in '.file' directive"); + } } if (FileNumber == -1) @@ -3317,12 +3330,16 @@ CKMem = (MD5::MD5Result *)Ctx.allocate(sizeof(MD5::MD5Result), 1); memcpy(&CKMem->Bytes, Checksum.data(), 16); } + if (HasSource) { + char *SourceBuf = static_cast(Ctx.allocate(SourceString.size())); + memcpy(SourceBuf, SourceString.data(), SourceString.size()); + Source = StringRef(SourceBuf, SourceString.size()); + } // If there is -g option as well as debug info from directive file, // we turn off -g option, directly use the existing debug info instead. if (getContext().getGenDwarfForAssembly()) getContext().setGenDwarfForAssembly(false); - else if (getStreamer().EmitDwarfFileDirective(FileNumber, Directory, - Filename, CKMem) == 0) + else if (getStreamer().EmitDwarfFileDirective(FileNumber, Directory, Filename, CKMem, Source) == 0) return Error(FileNumberLoc, "file number already allocated"); } Index: lib/MC/MCStreamer.cpp =================================================================== --- lib/MC/MCStreamer.cpp +++ lib/MC/MCStreamer.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCStreamer.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" @@ -192,8 +193,9 @@ StringRef Directory, StringRef Filename, MD5::MD5Result *Checksum, + Optional Source, unsigned CUID) { - return getContext().getDwarfFile(Directory, Filename, FileNo, Checksum, CUID); + return getContext().getDwarfFile(Directory, Filename, FileNo, Checksum, Source, CUID); } void MCStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line, Index: test/Assembler/debug-info.ll =================================================================== --- test/Assembler/debug-info.ll +++ test/Assembler/debug-info.ll @@ -1,8 +1,8 @@ ; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s ; RUN: verify-uselistorder %s -; CHECK: !named = !{!0, !0, !1, !2, !3, !4, !5, !6, !7, !8, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !27, !28, !29, !30, !31, !32, !33, !34, !35} -!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37, !38} +; CHECK: !named = !{!0, !0, !1, !2, !3, !4, !5, !6, !7, !8, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37} +!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37, !38, !39, !40} ; CHECK: !0 = !DISubrange(count: 3) ; CHECK-NEXT: !1 = !DISubrange(count: 3, lowerBound: 4) @@ -89,3 +89,8 @@ !36 = !DICompositeType(tag: DW_TAG_variant_part, name: "A", scope: !16, size: 64, discriminator: !37) !37 = !DIDerivedType(tag: DW_TAG_member, scope: !36, baseType: !38, size: 64, align: 64, flags: DIFlagArtificial) !38 = !DIBasicType(name: "u64", size: 64, encoding: DW_ATE_unsigned) + +; CHECK-NEXT: !36 = !DIFile(filename: "file", directory: "dir", source: "int source() { }\0A") +; CHECK-NEXT: !37 = !DIFile(filename: "file", directory: "dir", checksumkind: CSK_MD5, checksum: "3a420e2646916a475e68de8d48f779f5", source: "int source() { }\0A") +!39 = !DIFile(filename: "file", directory: "dir", source: "int source() { }\0A") +!40 = !DIFile(filename: "file", directory: "dir", checksumkind: CSK_MD5, checksum: "3a420e2646916a475e68de8d48f779f5", source: "int source() { }\0A") Index: test/Bitcode/metadata-source.ll =================================================================== --- /dev/null +++ test/Bitcode/metadata-source.ll @@ -0,0 +1,13 @@ +; Test that DIFile representation upgrades with introduction of +; optional source field. +; +; RUN: llvm-dis < %s.bc | FileCheck %s +; RUN: verify-uselistorder < %s.bc + +!llvm.dbg.cu = !{!1} +!llvm.module.flags = !{!3} + +!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 5.0.1 (tags/RELEASE_501/final)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) +; CHECK-NOT: !DIFile({{.*}}source:{{.*}}) +!2 = !DIFile(filename: "a.c", directory: "/test") +!3 = !{i32 2, !"Debug Info Version", i32 3} Index: test/CodeGen/BPF/dwarfdump.ll =================================================================== --- test/CodeGen/BPF/dwarfdump.ll +++ test/CodeGen/BPF/dwarfdump.ll @@ -59,6 +59,8 @@ !26 = !DILocation(line: 7, column: 17, scope: !2) !27 = !DILocation(line: 9, column: 9, scope: !2) -; CHECK: file_names[ 1] 0 0x00000000 0x00000000 "testprog.c" +; CHECK: file_names[ 1]: +; CHECK-NEXT: name: "testprog.c" +; CHECK-NEXT: dir_index: 0 ; CHECK: 0x0000000000000000 2 ; CHECK: 0x0000000000000028 7 Index: test/CodeGen/Generic/dwarf-md5.ll =================================================================== --- test/CodeGen/Generic/dwarf-md5.ll +++ test/CodeGen/Generic/dwarf-md5.ll @@ -16,13 +16,21 @@ ; ASM: .file 1 ".{{/|\\\\}}t1.h" md5 "11111111111111111111111111111111" ; ASM: .file 2 ".{{/|\\\\}}t2.h" md5 "22222222222222222222222222222222" -; OBJ-4: Dir Mod Time File Len File Name -; OBJ-4: file_names[ 1] 1 0x00000000 0x00000000 "t1.h" -; OBJ-4: file_names[ 2] 1 0x00000000 0x00000000 "t2.h" - -; OBJ-5: Dir MD5 Checksum File Name -; OBJ-5: file_names[ 0] 1 11111111111111111111111111111111 "t1.h" -; OBJ-5: file_names[ 1] 1 22222222222222222222222222222222 "t2.h" +; OBJ-4: file_names[ 1]: +; OBJ-4-NEXT: name: "t1.h" +; OBJ-4-NEXT: dir_index: 1 +; OBJ-4: file_names[ 2]: +; OBJ-4-NEXT: name: "t2.h" +; OBJ-4-NEXT: dir_index: 1 + +; OBJ-5: file_names[ 0]: +; OBJ-5-NEXT: name: "t1.h" +; OBJ-5-NEXT: dir_index: 1 +; OBJ-5-NEXT: md5_checksum: 11111111111111111111111111111111 +; OBJ-5: file_names[ 1]: +; OBJ-5-NEXT: name: "t2.h" +; OBJ-5-NEXT: dir_index: 1 +; OBJ-5-NEXT: md5_checksum: 22222222222222222222222222222222 ; ModuleID = 't.c' source_filename = "t.c" Index: test/CodeGen/Generic/dwarf-source.ll =================================================================== --- /dev/null +++ test/CodeGen/Generic/dwarf-source.ll @@ -0,0 +1,61 @@ +; Source text provided by IR should be passed through to asm. +; It is emitted to an object file only for DWARF 5 or later. + +; Darwin clamps the line table at DWARF v2 so XFAIL this test. +; XFAIL: darwin + +; REQUIRES: object-emission +; RUN: %llc_dwarf -dwarf-version 4 -filetype=asm -o - %s | FileCheck %s --check-prefix=ASM +; RUN: %llc_dwarf -dwarf-version 5 -filetype=asm -o - %s | FileCheck %s --check-prefix=ASM +; RUN: %llc_dwarf -dwarf-version 4 -filetype=obj -o %t4.o %s +; RUN: llvm-dwarfdump -debug-line %t4.o | FileCheck %s --check-prefix=OBJ-4 +; RUN: %llc_dwarf -dwarf-version 5 -filetype=obj -o %t5.o %s +; RUN: llvm-dwarfdump -debug-line %t5.o | FileCheck %s --check-prefix=OBJ-5 + +; FIXME: Need to convey the source for the primary source file. +; ASM: .file 1 ".{{/|\\\\}}t1.h" source "11111111111111111111111111111111" +; ASM: .file 2 ".{{/|\\\\}}t2.h" source "22222222222222222222222222222222" + +; OBJ-4: file_names[ 1]: +; OBJ-4-NEXT: name: "t1.h" +; OBJ-4-NEXT: dir_index: 1 +; OBJ-4-NOT: 11111111111111111111111111111111 +; OBJ-4: file_names[ 2]: +; OBJ-4-NEXT: name: "t2.h" +; OBJ-4-NEXT: dir_index: 1 +; OBJ-4-NOT: 22222222222222222222222222222222 + +; OBJ-5: file_names[ 0]: +; OBJ-5-NEXT: name: "t1.h" +; OBJ-5-NEXT: dir_index: 1 +; OBJ-5-NEXT: source: "11111111111111111111111111111111" +; OBJ-5: file_names[ 1]: +; OBJ-5-NEXT: name: "t2.h" +; OBJ-5-NEXT: dir_index: 1 +; OBJ-5-NEXT: source: "22222222222222222222222222222222" + +; ModuleID = 't.c' +source_filename = "t.c" + +@t1 = global i32 1, align 4, !dbg !0 +@t2 = global i32 0, align 4, !dbg !6 + +!llvm.dbg.cu = !{!2} +!llvm.module.flags = !{!11, !12, !13} +!llvm.ident = !{!14} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "t1", scope: !2, file: !10, line: 1, type: !9, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (trunk 322159)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5) +!3 = !DIFile(filename: "t.c", directory: "/test", source: "00000000000000000000000000000000") +!4 = !{} +!5 = !{!0, !6} +!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) +!7 = distinct !DIGlobalVariable(name: "t2", scope: !2, file: !8, line: 1, type: !9, isLocal: false, isDefinition: true) +!8 = !DIFile(filename: "./t2.h", directory: "/test", source: "22222222222222222222222222222222") +!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!10 = !DIFile(filename: "./t1.h", directory: "/test", source: "11111111111111111111111111111111") +!11 = !{i32 2, !"Dwarf Version", i32 4} +!12 = !{i32 2, !"Debug Info Version", i32 3} +!13 = !{i32 1, !"wchar_size", i32 4} +!14 = !{!"clang version 7.0.0 (trunk 322159)"} Index: test/CodeGen/X86/dwarf-comp-dir.ll =================================================================== --- test/CodeGen/X86/dwarf-comp-dir.ll +++ test/CodeGen/X86/dwarf-comp-dir.ll @@ -15,7 +15,7 @@ !7 = !{!6} ; The important part of the following check is that dir = #0. -; Dir Mod Time File Len File Name -; ---- ---------- ---------- --------------------------- -; CHECK: file_names[ 1] 0 0x00000000 0x00000000 "empty.c" +; CHECK: file_names[ 1]: +; CHECK-NEXT: name: "empty.c" +; CHECK-NEXT: dir_index: 0 !5 = !{i32 1, !"Debug Info Version", i32 3} Index: test/DebugInfo/AMDGPU/dwarfdump-relocs.ll =================================================================== --- test/DebugInfo/AMDGPU/dwarfdump-relocs.ll +++ test/DebugInfo/AMDGPU/dwarfdump-relocs.ll @@ -13,7 +13,9 @@ ; } ; CHECK-NOT: failed to compute relocation -; CHECK: file_names[ 1] 0 0x00000000 0x00000000 "dwarfdump-relocs.cl" +; CHECK: file_names[ 1]: +; CHECK-NEXT: name: "dwarfdump-relocs.cl" +; CHECK-NEXT: dir_index: 0 declare void @llvm.dbg.declare(metadata, metadata, metadata) Index: test/DebugInfo/Generic/lto-comp-dir.ll =================================================================== --- test/DebugInfo/Generic/lto-comp-dir.ll +++ test/DebugInfo/Generic/lto-comp-dir.ll @@ -11,13 +11,17 @@ ; CHECK-NEXT: debug_line[{{.*}}] ; CHECK-NEXT: Line table prologue: ; CHECK-NOT: include_directories -; CHECK: file_names[ 1] 0 {{.*}} "a.cpp" +; CHECK: file_names[ 1] +; CHECK: name: "a.cpp" +; CHECK-NEXT: dir_index: 0 ; CHECK-NOT: file_names ; CHECK: debug_line[{{.*}}] ; CHECK-NEXT: Line table prologue: ; CHECK-NOT: include_directories -; CHECK: file_names[ 1] 0 {{.*}} "b.cpp" +; CHECK: file_names[ 1] +; CHECK: name: "b.cpp" +; CHECK-NEXT: dir_index: 0 ; CHECK-NOT: file_names ; However, if a single line table is emitted and shared between CUs, the Index: test/DebugInfo/X86/debug-macro.ll =================================================================== --- test/DebugInfo/X86/debug-macro.ll +++ test/DebugInfo/X86/debug-macro.ll @@ -28,11 +28,12 @@ ; CHECK-NEXT: DW_MACINFO_end_file ; CHECK-LABEL: .debug_line contents: -; CHECK: Dir Mod Time File Len File Name -; CHECK: file_names[ 1] {{.*}}debug-macro.cpp -; CHECK: file_names[ 2] {{.*}}debug-macro.h -; CHECK: Dir Mod Time File Len File Name -; CHECK: file_names[ 1] {{.*}}debug-macro1.cpp +; CHECK: file_names[ 1]: +; CHECK: name: "debug-macro.cpp" +; CHECK: file_names[ 2]: +; CHECK: name: "debug-macro.h" +; CHECK: file_names[ 1]: +; CHECK: name: "debug-macro1.cpp" !llvm.dbg.cu = !{!0, !16, !20} !llvm.module.flags = !{!13, !14} Index: test/DebugInfo/X86/dwarfdump-header-64.s =================================================================== --- test/DebugInfo/X86/dwarfdump-header-64.s +++ test/DebugInfo/X86/dwarfdump-header-64.s @@ -144,6 +144,14 @@ # CHECK: include_directories[ 0] = .debug_str[0x00000028] = "Directory5a" # CHECK: include_directories[ 1] = .debug_str[0x00000034] = "Directory5b" # CHECK-NOT: include_directories -# CHECK: file_names[ 0] 0 0x00000051 0x00000052 "File5a" -# CHECK: file_names[ 1] 1 0x00000053 0x00000054 "File5b" +# CHECK: file_names[ 0]: +# CHECK-NEXT: name: "File5a" +# CHECK-NEXT: dir_index: 0 +# CHECK-NEXT: mod_time: 0x00000051 +# CHECK-NEXT: length: 0x00000052 +# CHECK: file_names[ 1]: +# CHECK-NEXT: name: "File5b" +# CHECK-NEXT: dir_index: 1 +# CHECK-NEXT: mod_time: 0x00000053 +# CHECK-NEXT: length: 0x00000054 # CHECK-NOT: file_names Index: test/DebugInfo/X86/dwarfdump-header.s =================================================================== --- test/DebugInfo/X86/dwarfdump-header.s +++ test/DebugInfo/X86/dwarfdump-header.s @@ -258,8 +258,16 @@ # CHECK: include_directories[ 1] = "Directory4a" # CHECK: include_directories[ 2] = "Directory4b" # CHECK-NOT: include_directories -# CHECK: file_names[ 1] 1 0x00000041 0x00000042 "File4a" -# CHECK: file_names[ 2] 0 0x00000043 0x00000044 "File4b" +# CHECK: file_names[ 1]: +# CHECK-NEXT: name: "File4a" +# CHECK-NEXT: dir_index: 1 +# CHECK-NEXT: mod_time: 0x00000041 +# CHECK-NEXT: length: 0x00000042 +# CHECK: file_names[ 2]: +# CHECK-NEXT: name: "File4b" +# CHECK-NEXT: dir_index: 0 +# CHECK-NEXT: mod_time: 0x00000043 +# CHECK-NEXT: length: 0x00000044 # CHECK-NOT: file_names # DWARF v5 line-table header. @@ -329,9 +337,14 @@ # CHECK: include_directories[ 0] = .debug_str[0x00000045] = "Directory5a" # CHECK: include_directories[ 1] = .debug_str[0x00000051] = "Directory5b" # CHECK-NOT: include_directories -# CHECK: MD5 Checksum -# CHECK: file_names[ 0] 0 00112233445566778899aabbccddeeff .debug_line_str[0x00000000] = "File5a" -# CHECK: file_names[ 1] 1 ffeeddccbbaa99887766554433221100 .debug_line_str[0x00000007] = "File5b" +# CHECK: file_names[ 0]: +# CHECK-NEXT: name: .debug_line_str[0x00000000] = "File5a" +# CHECK-NEXT: dir_index: 0 +# CHECK-NEXT: md5_checksum: 00112233445566778899aabbccddeeff +# CHECK: file_names[ 1]: +# CHECK-NEXT: name: .debug_line_str[0x00000007] = "File5b" +# CHECK-NEXT: dir_index: 1 +# CHECK-NEXT: md5_checksum: ffeeddccbbaa99887766554433221100 # CHECK-NOT: file_names .section .debug_line_str,"MS",@progbits,1 @@ -410,6 +423,14 @@ # CHECK: include_directories[ 0] = .debug_str[0x0000003d] = "DWODirectory5a" # CHECK: include_directories[ 1] = .debug_str[0x0000004c] = "DWODirectory5b" # CHECK-NOT: include_directories -# CHECK: file_names[ 0] 0 0x00000015 0x00000025 "DWOFile5a" -# CHECK: file_names[ 1] 1 0x00000035 0x00000045 "DWOFile5b" +# CHECK: file_names[ 0]: +# CHECK-NEXT: name: "DWOFile5a" +# CHECK-NEXT: dir_index: 0 +# CHECK-NEXT: mod_time: 0x00000015 +# CHECK-NEXT: length: 0x00000025 +# CHECK: file_names[ 1]: +# CHECK-NEXT: name: "DWOFile5b" +# CHECK-NEXT: dir_index: 1 +# CHECK-NEXT: mod_time: 0x00000035 +# CHECK-NEXT: length: 0x00000045 # CHECK-NOT: file_names Index: test/DebugInfo/X86/dwarfdump-line-dwo.s =================================================================== --- test/DebugInfo/X86/dwarfdump-line-dwo.s +++ test/DebugInfo/X86/dwarfdump-line-dwo.s @@ -47,7 +47,8 @@ # PART1-NEXT: version: 4 # PART1-NEXT: prologue_length: 0x00000028 # PART1: include_directories[ 1] = "Directory1" -# PART1: file_names[ 1] {{.*}} "File1" +# PART1: file_names[ 1] +# PART1: name: "File1" # Second line table. LH_2_start: @@ -93,5 +94,6 @@ # PART2-NEXT: prologue_length: 0x00000022 # PART2-NOT: prologue: # PART2: include_directories[ 1] = "Dir2" -# PART2: file_names[ 1] {{.*}} "File2" +# PART2: file_names[ 1] +# PART2: name: "File2" # PART2-NOT: prologue: Index: test/DebugInfo/X86/dwarfdump-line-only.s =================================================================== --- test/DebugInfo/X86/dwarfdump-line-only.s +++ test/DebugInfo/X86/dwarfdump-line-only.s @@ -94,7 +94,15 @@ # CHECK: include_directories[ 0] = .debug_str[0x00000000] = "Directory1" # CHECK: include_directories[ 1] = .debug_str[0x0000000b] = "Directory2" # CHECK-NOT: include_directories -# CHECK: file_names[ 0] 1 0x00000051 0x00000052 .debug_line_str[0x00000000] = "File1" -# CHECK: file_names[ 1] 0 0x00000053 0x00000054 .debug_line_str[0x00000006] = "File2" +# CHECK: file_names[ 0]: +# CHECK-NEXT: name: .debug_line_str[0x00000000] = "File1" +# CHECK-NEXT: dir_index: 1 +# CHECK-NEXT: mod_time: 0x00000051 +# CHECK-NEXT: length: 0x00000052 +# CHECK: file_names[ 1]: +# CHECK-NEXT: name: .debug_line_str[0x00000006] = "File2" +# CHECK-NEXT: dir_index: 0 +# CHECK-NEXT: mod_time: 0x00000053 +# CHECK-NEXT: length: 0x00000054 # CHECK-NOT: file_names # CHECK: 0x0000000000000000 {{.*}} is_stmt end_sequence Index: test/DebugInfo/X86/generate-odr-hash.ll =================================================================== --- test/DebugInfo/X86/generate-odr-hash.ll +++ test/DebugInfo/X86/generate-odr-hash.ll @@ -122,8 +122,10 @@ ; CHECK-LABEL: .debug_line contents: ; CHECK: Line table prologue ; CHECK-NOT: file_names[ -; SINGLE: file_names{{.*}} "bar.h" -; CHECK: file_names{{.*}} "bar.cpp" +; SINGLE: file_names{{.*}} +; SINGLE: name: "bar.h" +; CHECK: file_names{{.*}} +; CHECK: name: "bar.cpp" ; CHECK-NOT: file_names[ ; FISSION: .debug_line.dwo contents: @@ -133,8 +135,10 @@ ; FISSION-NOT: standard_opcode_lengths ; FISSION-NOT: include_directories ; FISSION-NOT: file_names[ -; FISSION: file_names{{.*}} "bar.h" -; FISSION: file_names{{.*}} "bar.cpp" +; FISSION: file_names{{.*}} +; FISSION: name: "bar.h" +; FISSION: file_names{{.*}} +; FISSION: name: "bar.cpp" ; FISSION-NOT: file_names[ ; CHECK-LABEL: .debug_str contents: Index: test/DebugInfo/X86/stmt-list-multiple-compile-units.ll =================================================================== --- test/DebugInfo/X86/stmt-list-multiple-compile-units.ll +++ test/DebugInfo/X86/stmt-list-multiple-compile-units.ll @@ -27,11 +27,15 @@ ; CHECK-NEXT: debug_line[{{.*}}] ; CHECK-NEXT: Line table prologue: ; CHECK-NEXT: total_length: 0x00000038 -; CHECK: file_names[ 1] 0 0x00000000 0x00000000 "simple.c" +; CHECK: file_names[ 1]: +; CHECK-NEXT: name: "simple.c" +; CHECK-NEXT: dir_index: 0 ; CHECK: debug_line[{{.*}}] ; CHECK-NEXT: Line table prologue: ; CHECK-NEXT: total_length: 0x00000039 -; CHECK: file_names[ 1] 0 0x00000000 0x00000000 "simple2.c" +; CHECK: file_names[ 1]: +; CHECK-NEXT: name: "simple2.c" +; CHECK-NEXT: dir_index: 0 ; CHECK-NOT: file_names ; DWARF3: .debug_info contents: @@ -46,11 +50,15 @@ ; DWARF3-NEXT: debug_line[{{.*}}] ; DWARF3-NEXT: Line table prologue: ; DWARF3-NEXT: total_length: 0x00000038 -; DWARF3: file_names[ 1] 0 0x00000000 0x00000000 "simple.c" +; DWARF3: file_names[ 1]: +; DWARF3-NEXT: name: "simple.c" +; DWARF3-NEXT: dir_index: 0 ; DWARF3: debug_line[{{.*}}] ; DWARF3-NEXT: Line table prologue: ; DWARF3-NEXT: total_length: 0x00000039 -; DWARF3: file_names[ 1] 0 0x00000000 0x00000000 "simple2.c" +; DWARF3: file_names[ 1]: +; DWARF3-NEXT: name: "simple2.c" +; DWARF3-NEXT: dir_index: 0 ; DWARF3-NOT: file_names ; PR15408 Index: test/DebugInfo/debugmacinfo.test =================================================================== --- test/DebugInfo/debugmacinfo.test +++ test/DebugInfo/debugmacinfo.test @@ -22,6 +22,12 @@ TEST_MACINFO: DW_MACINFO_end_file TEST_LINE: .debug_line contents: -TEST_LINE: file_names[ 1] 0 0x00000000 0x00000000 "dwarfdump-macro.cc" -TEST_LINE: file_names[ 2] 1 0x00000000 0x00000000 "dwarfdump-macro-cmd.h" -TEST_LINE: file_names[ 3] 0 0x00000000 0x00000000 "dwarfdump-macro.h" +TEST_LINE: file_names[ 1]: +TEST_LINE-NEXT: name: "dwarfdump-macro.cc" +TEST_LINE-NEXT: dir_index: 0 +TEST_LINE: file_names[ 2]: +TEST_LINE-NEXT: name: "dwarfdump-macro-cmd.h" +TEST_LINE-NEXT: dir_index: 1 +TEST_LINE: file_names[ 3]: +TEST_LINE-NEXT: name: "dwarfdump-macro.h" +TEST_LINE-NEXT: dir_index: 0 Index: test/Linker/Inputs/metadata-source-a.ll =================================================================== --- /dev/null +++ test/Linker/Inputs/metadata-source-a.ll @@ -0,0 +1,22 @@ +; ModuleID = 'a.c' +source_filename = "a.c" +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@a = common global i32 0, align 4, !dbg !0 + +!llvm.dbg.cu = !{!2} +!llvm.module.flags = !{!7, !8, !9} +!llvm.ident = !{!10} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (https://git.llvm.org/git/clang.git/ c12b573f9ac61655cce52628b34235f58edaf984) (https://scott.linder@llvm.org/git/llvm.git 90c4822e8541eb07891cd03e614c530c30f8aa12)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5) +!3 = !DIFile(filename: "a.c", directory: "/home/slinder1/test/link", source: "int a;\0A") +!4 = !{} +!5 = !{!0} +!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!7 = !{i32 2, !"Dwarf Version", i32 4} +!8 = !{i32 2, !"Debug Info Version", i32 3} +!9 = !{i32 1, !"wchar_size", i32 4} +!10 = !{!"clang version 7.0.0 (https://git.llvm.org/git/clang.git/ c12b573f9ac61655cce52628b34235f58edaf984) (https://scott.linder@llvm.org/git/llvm.git 90c4822e8541eb07891cd03e614c530c30f8aa12)"} Index: test/Linker/Inputs/metadata-source-b.ll =================================================================== --- /dev/null +++ test/Linker/Inputs/metadata-source-b.ll @@ -0,0 +1,22 @@ +; ModuleID = 'b.c' +source_filename = "b.c" +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@b = common global i32 0, align 4, !dbg !0 + +!llvm.dbg.cu = !{!2} +!llvm.module.flags = !{!7, !8, !9} +!llvm.ident = !{!10} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (https://git.llvm.org/git/clang.git/ c12b573f9ac61655cce52628b34235f58edaf984) (https://scott.linder@llvm.org/git/llvm.git 90c4822e8541eb07891cd03e614c530c30f8aa12)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5) +!3 = !DIFile(filename: "b.c", directory: "/home/slinder1/test/link", source: "int b;\0A") +!4 = !{} +!5 = !{!0} +!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!7 = !{i32 2, !"Dwarf Version", i32 4} +!8 = !{i32 2, !"Debug Info Version", i32 3} +!9 = !{i32 1, !"wchar_size", i32 4} +!10 = !{!"clang version 7.0.0 (https://git.llvm.org/git/clang.git/ c12b573f9ac61655cce52628b34235f58edaf984) (https://scott.linder@llvm.org/git/llvm.git 90c4822e8541eb07891cd03e614c530c30f8aa12)"} Index: test/Linker/metadata-source.ll =================================================================== --- /dev/null +++ test/Linker/metadata-source.ll @@ -0,0 +1,4 @@ +; RUN: llvm-link %p/Inputs/metadata-source-a.ll %p/Inputs/metadata-source-b.ll -S | FileCheck %s + +; CHECK: !DIFile(filename: "a.c", directory: "/home/slinder1/test/link", source: "int a;\0A") +; CHECK: !DIFile(filename: "b.c", directory: "/home/slinder1/test/link", source: "int b;\0A") Index: test/Linker/subprogram-linkonce-weak.ll =================================================================== --- test/Linker/subprogram-linkonce-weak.ll +++ test/Linker/subprogram-linkonce-weak.ll @@ -147,14 +147,18 @@ ; DW-LABEL: .debug_line contents: ; Check that we have the right things in the line table as well. -; DWLW-LABEL: file_names[{{ *}}1]{{.*}} "bar.c" +; DWLW-LABEL: file_names[ 1]{{.*}} +; DWLW: name: "bar.c" ; DWLW: 2 0 1 0 0 is_stmt prologue_end -; DWLW-LABEL: file_names[{{ *}}1]{{.*}} "foo.c" +; DWLW-LABEL: file_names[ 1]{{.*}} +; DWLW: name: "foo.c" ; DWLW: 52 0 1 0 0 is_stmt prologue_end ; DWLW-NOT: prologue_end -; DWWL-LABEL: file_names[{{ *}}1]{{.*}} "foo.c" +; DWWL-LABEL: file_names[ 1]{{.*}} +; DWWL: name: "foo.c" ; DWWL: 52 0 1 0 0 is_stmt prologue_end -; DWWL-LABEL: file_names[{{ *}}1]{{.*}} "bar.c" +; DWWL-LABEL: file_names[ 1]{{.*}} +; DWWL: name: "bar.c" ; DWWL: 2 0 1 0 0 is_stmt prologue_end ; DWWL-NOT: prologue_end Index: test/MC/ARM/dwarf-asm-multiple-sections.s =================================================================== --- test/MC/ARM/dwarf-asm-multiple-sections.s +++ test/MC/ARM/dwarf-asm-multiple-sections.s @@ -55,7 +55,8 @@ // DWARF-DL: version: [[DWVER]] // DWARF-DL-5: address_size: 4 // DWARF-DL-5: include_directories[ 0] = "" -// DWARF-DL: file_names[ [[DWFILE]]] {{.*}} "" +// DWARF-DL: file_names[ [[DWFILE]]]: +// DWARF-DL: name: "" // DWARF-DL: 0x0000000000000000 17 0 1 0 0 is_stmt // DWARF-DL-NEXT: 0x0000000000000004 17 0 1 0 0 is_stmt end_sequence // DWARF-DL-NEXT: 0x0000000000000000 21 0 1 0 0 is_stmt Index: test/MC/AsmParser/debug-empty-source.s =================================================================== --- /dev/null +++ test/MC/AsmParser/debug-empty-source.s @@ -0,0 +1,7 @@ +// RUN: llvm-mc %s -o -| FileCheck %s + +.file 1 "dir1" "foo" source "" +.loc 1 1 0 +nop + +# CHECK: .file {{.*}} source "" Index: test/MC/AsmParser/debug-no-source.s =================================================================== --- /dev/null +++ test/MC/AsmParser/debug-no-source.s @@ -0,0 +1,5 @@ +// RUN: llvm-mc %s | FileCheck %s + +.file 1 "dir1/foo" + +# CHECK-NOT: .file {{.*}} source Index: test/MC/ELF/debug-file-options.s =================================================================== --- /dev/null +++ test/MC/ELF/debug-file-options.s @@ -0,0 +1,36 @@ +// RUN: llvm-mc -triple x86_64-unknown-unknown -dwarf-version 5 -filetype=obj %s -o -| llvm-dwarfdump --debug-line --debug-line-str -v - | FileCheck %s + +// Test combinations of options to the .file directive. + + .file 1 "dir1/foo" md5 "ee87e05688663173cd6043a3a15bba6e" source "void foo() {}" + .file 2 "dir2/bar" source "void bar() {}" md5 "816225a0c90ca8948b70eb58be4d522f" + .loc 1 1 0 + nop + .loc 2 1 0 + nop + +# CHECK: debug_line[0x00000000] +# CHECK: version: 5 +# CHECK: include_directories[ 0] = .debug_line_str[0x[[DIR0:[0-9a-f]+]]] = "" +# CHECK: include_directories[ 1] = .debug_line_str[0x[[DIR1:[0-9a-f]+]]] = "dir1" +# CHECK: include_directories[ 2] = .debug_line_str[0x[[DIR2:[0-9a-f]+]]] = "dir2" +# CHECK-NOT: include_directories +# CHECK: file_names[ 0]: +# CHECK-NEXT: name: .debug_line_str[0x[[FILE1:[0-9a-f]+]]] = "foo" +# CHECK-NEXT: dir_index: 1 +# CHECK-NEXT: md5_checksum: ee87e05688663173cd6043a3a15bba6e +# CHECK-NEXT: source: .debug_line_str[0x[[FILE1SRC:[0-9a-f]+]]] = "void foo() {}" +# CHECK: file_names[ 1]: +# CHECK-NEXT: name: .debug_line_str[0x[[FILE2:[0-9a-f]+]]] = "bar" +# CHECK-NEXT: dir_index: 2 +# CHECK-NEXT: md5_checksum: 816225a0c90ca8948b70eb58be4d522f +# CHECK-NEXT: source: .debug_line_str[0x[[FILE2SRC:[0-9a-f]+]]] = "void bar() {}" + +# CHECK: .debug_line_str contents: +# CHECK-NEXT: 0x[[DIR0]]: "" +# CHECK-NEXT: 0x[[DIR1]]: "dir1" +# CHECK-NEXT: 0x[[DIR2]]: "dir2" +# CHECK-NEXT: 0x[[FILE1]]: "foo" +# CHECK-NEXT: 0x[[FILE1SRC]]: "void foo() {}" +# CHECK-NEXT: 0x[[FILE2]]: "bar" +# CHECK-NEXT: 0x[[FILE2SRC]]: "void bar() {}" Index: test/MC/ELF/debug-md5.s =================================================================== --- test/MC/ELF/debug-md5.s +++ test/MC/ELF/debug-md5.s @@ -13,9 +13,14 @@ # CHECK: include_directories[ 1] = .debug_line_str[0x[[DIR1:[0-9a-f]+]]] = "dir1" # CHECK: include_directories[ 2] = .debug_line_str[0x[[DIR2:[0-9a-f]+]]] = "dir2" # CHECK-NOT: include_directories -# CHECK: Dir MD5 Checksum File Name -# CHECK: file_names[ 0] 1 00112233445566778899aabbccddeeff .debug_line_str[0x[[FILE1:[0-9a-f]+]]] = "foo" -# CHECK: file_names[ 1] 2 ffeeddccbbaa99887766554433221100 .debug_line_str[0x[[FILE2:[0-9a-f]+]]] = "bar" +# CHECK: file_names[ 0]: +# CHECK-NEXT: name: .debug_line_str[0x[[FILE1:[0-9a-f]+]]] = "foo" +# CHECK-NEXT: dir_index: 1 +# CHECK-NEXT: md5_checksum: 00112233445566778899aabbccddeeff +# CHECK: file_names[ 1]: +# CHECK-NEXT: name: .debug_line_str[0x[[FILE2:[0-9a-f]+]]] = "bar" +# CHECK-NEXT: dir_index: 2 +# CHECK-NEXT: md5_checksum: ffeeddccbbaa99887766554433221100 # CHECK: .debug_line_str contents: # CHECK-NEXT: 0x[[DIR0]]: "" Index: test/MC/ELF/debug-source.s =================================================================== --- /dev/null +++ test/MC/ELF/debug-source.s @@ -0,0 +1,32 @@ +// RUN: llvm-mc -triple x86_64-unknown-unknown -dwarf-version 5 -filetype=obj %s -o -| llvm-dwarfdump --debug-line --debug-line-str -v - | FileCheck %s + + .file 1 "dir1/foo" source "void foo() {}" + .file 2 "dir2" "bar" source "void bar()\n{\n}" + .loc 1 1 0 + nop + .loc 2 1 0 + nop + +# CHECK: debug_line[0x00000000] +# CHECK: version: 5 +# CHECK: include_directories[ 0] = .debug_line_str[0x[[DIR0:[0-9a-f]+]]] = "" +# CHECK: include_directories[ 1] = .debug_line_str[0x[[DIR1:[0-9a-f]+]]] = "dir1" +# CHECK: include_directories[ 2] = .debug_line_str[0x[[DIR2:[0-9a-f]+]]] = "dir2" +# CHECK-NOT: include_directories +# CHECK: file_names[ 0]: +# CHECK-NEXT: name: .debug_line_str[0x[[FILE1:[0-9a-f]+]]] = "foo" +# CHECK-NEXT: dir_index: 1 +# CHECK-NEXT: source: .debug_line_str[0x[[FILE1SRC:[0-9a-f]+]]] = "void foo() {}" +# CHECK: file_names[ 1]: +# CHECK-NEXT: name: .debug_line_str[0x[[FILE2:[0-9a-f]+]]] = "bar" +# CHECK-NEXT: dir_index: 2 +# CHECK-NEXT: source: .debug_line_str[0x[[FILE2SRC:[0-9a-f]+]]] = "void bar()\n{\n}" + +# CHECK: .debug_line_str contents: +# CHECK-NEXT: 0x[[DIR0]]: "" +# CHECK-NEXT: 0x[[DIR1]]: "dir1" +# CHECK-NEXT: 0x[[DIR2]]: "dir2" +# CHECK-NEXT: 0x[[FILE1]]: "foo" +# CHECK-NEXT: 0x[[FILE1SRC]]: "void foo() {}" +# CHECK-NEXT: 0x[[FILE2]]: "bar" +# CHECK-NEXT: 0x[[FILE2SRC]]: "void bar()\n{\n}" Index: test/MC/MachO/gen-dwarf-cpp.s =================================================================== --- test/MC/MachO/gen-dwarf-cpp.s +++ test/MC/MachO/gen-dwarf-cpp.s @@ -16,11 +16,15 @@ // We check that the source name "t.s" is picked up // CHECK: include_directories[ 1] = "{{.*(/|\\\\)}}test{{(/|\\\\)}}MC{{(/|\\\\)}}MachO" // CHECK: include_directories[ 2] = "inc" -// CHECK: Dir Mod Time File Len File Name -// CHECK: ---- ---------- ---------- --------------------------- -// CHECK: file_names[ 1] 1 0x00000000 0x00000000 "gen-dwarf-cpp.s" -// CHECK: file_names[ 2] 0 0x00000000 0x00000000 "t.s" -// CHECK: file_names[ 3] 2 0x00000000 0x00000000 "g.s" +// CHECK: file_names[ 1]: +// CHECK-NEXT: name: "gen-dwarf-cpp.s" +// CHECK-NEXT: dir_index: 1 +// CHECK: file_names[ 2]: +// CHECK-NEXT: name: "t.s" +// CHECK-NEXT: dir_index: 0 +// CHECK: file_names[ 3]: +// CHECK-NEXT: name: "g.s" +// CHECK-NEXT: dir_index: 2 // CHECK-NOT: file_names // We check that the source line number 100 is picked up before the "movl" Index: test/MC/MachO/gen-dwarf-macro-cpp.s =================================================================== --- test/MC/MachO/gen-dwarf-macro-cpp.s +++ test/MC/MachO/gen-dwarf-macro-cpp.s @@ -11,7 +11,9 @@ // rdar://12637628 // We check that the source name "foo.S" is picked up -// CHECK: Dir Mod Time File Len File Name -// CHECK: ---- ---------- ---------- --------------------------- -// CHECK: file_names[ 1] 1 0x00000000 0x00000000 "gen-dwarf-macro-cpp.s" -// CHECK: file_names[ 2] 0 0x00000000 0x00000000 "foo.S" +// CHECK: file_names[ 1]: +// CHECK-NEXT: name: "gen-dwarf-macro-cpp.s" +// CHECK-NEXT: dir_index: 1 +// CHECK: file_names[ 2]: +// CHECK-NEXT: name: "foo.S" +// CHECK-NEXT: dir_index: 0 Index: test/MC/MachO/gen-dwarf.s =================================================================== --- test/MC/MachO/gen-dwarf.s +++ test/MC/MachO/gen-dwarf.s @@ -109,9 +109,9 @@ // CHECK: standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0 // CHECK: standard_opcode_lengths[DW_LNS_set_isa] = 1 // We don't check include_directories as it has a temp path -// CHECK: Dir Mod Time File Len File Name -// CHECK: ---- ---------- ---------- --------------------------- -// CHECK: file_names[ 1] 1 0x00000000 0x00000000 "gen-dwarf.s" +// CHECK: file_names[ 1]: +// CHECK-NEXT: name: "gen-dwarf.s" +// CHECK-NEXT: dir_index: 1 // CHECK: Address Line Column File ISA Discriminator Flags // CHECK: ------------------ ------ ------ ------ --- ------------- ------------- Index: test/tools/dsymutil/X86/basic-linking-x86.test =================================================================== --- test/tools/dsymutil/X86/basic-linking-x86.test +++ test/tools/dsymutil/X86/basic-linking-x86.test @@ -153,18 +153,18 @@ CHECK-NEXT:[0x0000000100000f90, 0x0000000100000fa9) CHECK: .debug_line contents: -CHECK: Dir Mod Time File Len File Name -CHECK-NEXT: ---- ---------- ---------- --------------------------- -CHECK-NEXT: file_names[ 1] 0 0x00000000 0x00000000 "basic1.c" +CHECK: file_names[ 1]: +CHECK-NEXT: name: "basic1.c" +CHECK-NEXT: dir_index: 0 CHECK: Address Line Column File ISA Discriminator Flags CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------------- CHECK-NEXT: 0x0000000100000ea0 23 0 1 0 0 is_stmt CHECK-NEXT: 0x0000000100000eb6 24 0 1 0 0 is_stmt prologue_end CHECK-NEXT: 0x0000000100000ec4 24 0 1 0 0 is_stmt end_sequence -CHECK: Dir Mod Time File Len File Name -CHECK-NEXT: ---- ---------- ---------- --------------------------- -CHECK-NEXT: file_names[ 1] 0 0x00000000 0x00000000 "basic2.c" +CHECK: file_names[ 1]: +CHECK-NEXT: name: "basic2.c" +CHECK-NEXT: dir_index: 0 CHECK: Address Line Column File ISA Discriminator Flags CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------------- CHECK-NEXT: 0x0000000100000ed0 19 0 1 0 0 is_stmt @@ -174,9 +174,9 @@ CHECK-NEXT: 0x0000000100000f24 15 0 1 0 0 is_stmt prologue_end CHECK-NEXT: 0x0000000100000f37 15 0 1 0 0 is_stmt end_sequence -CHECK: Dir Mod Time File Len File Name -CHECK-NEXT: ---- ---------- ---------- --------------------------- -CHECK-NEXT: file_names[ 1] 0 0x00000000 0x00000000 "basic3.c" +CHECK: file_names[ 1]: +CHECK-NEXT: name: "basic3.c" +CHECK-NEXT: dir_index: 0 CHECK: Address Line Column File ISA Discriminator Flags CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------------- CHECK-NEXT: 0x0000000100000f40 16 0 1 0 0 is_stmt Index: test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test =================================================================== --- test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test +++ test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test @@ -138,9 +138,9 @@ CHECK-NEXT: [0x0000000100000f90, 0x0000000100000fb4) CHECK: .debug_line contents: -CHECK: Dir Mod Time File Len File Name -CHECK-NEXT: ---- ---------- ---------- --------------------------- -CHECK-NEXT: file_names[ 1] 0 0x00000000 0x00000000 "basic1.c" +CHECK: file_names[ 1]: +CHECK-NEXT: name: "basic1.c" +CHECK-NEXT: dir_index: 0 CHECK: Address Line Column File ISA Discriminator Flags CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------------- CHECK-NEXT: 0x0000000100000f40 26 0 1 0 0 is_stmt @@ -148,9 +148,9 @@ CHECK-NEXT: 0x0000000100000f49 27 3 1 0 0 CHECK-NEXT: 0x0000000100000f4b 27 3 1 0 0 end_sequence -CHECK: Dir Mod Time File Len File Name -CHECK-NEXT: ---- ---------- ---------- --------------------------- -CHECK-NEXT: file_names[ 1] 0 0x00000000 0x00000000 "basic2.c" +CHECK: file_names[ 1]: +CHECK-NEXT: name: "basic2.c" +CHECK-NEXT: dir_index: 0 CHECK: Address Line Column File ISA Discriminator Flags CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------------- CHECK-NEXT: 0x0000000100000f50 19 0 1 0 0 is_stmt @@ -164,9 +164,9 @@ CHECK-NEXT: 0x0000000100000f85 20 3 1 0 0 CHECK-NEXT: 0x0000000100000f87 20 3 1 0 0 end_sequence -CHECK: Dir Mod Time File Len File Name -CHECK-NEXT: ---- ---------- ---------- --------------------------- -CHECK-NEXT: file_names[ 1] 0 0x00000000 0x00000000 "basic3.c" +CHECK: file_names[ 1]: +CHECK-NEXT: name: "basic3.c" +CHECK-NEXT: dir_index: 0 CHECK: Address Line Column File ISA Discriminator Flags CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------------- CHECK-NEXT: 0x0000000100000f90 16 0 1 0 0 is_stmt Index: test/tools/dsymutil/X86/basic-lto-linking-x86.test =================================================================== --- test/tools/dsymutil/X86/basic-lto-linking-x86.test +++ test/tools/dsymutil/X86/basic-lto-linking-x86.test @@ -150,25 +150,25 @@ CHECK: .debug_line contents -CHECK: Dir Mod Time File Len File Name -CHECK-NEXT: ---- ---------- ---------- --------------------------- -CHECK-NEXT: file_names[ 1] 0 0x00000000 0x00000000 "basic1.c" +CHECK: file_names[ 1]: +CHECK-NEXT: name: "basic1.c" +CHECK-NEXT: dir_index: 0 CHECK: 0x0000000100000f40 23 0 1 0 0 is_stmt CHECK: 0x0000000100000f44 24 0 1 0 0 is_stmt prologue_end CHECK: 0x0000000100000f4b 24 0 1 0 0 is_stmt end_sequence -CHECK: Dir Mod Time File Len File Name -CHECK-NEXT: ---- ---------- ---------- --------------------------- -CHECK-NEXT: file_names[ 1] 0 0x00000000 0x00000000 "basic2.c" +CHECK: file_names[ 1]: +CHECK-NEXT: name: "basic2.c" +CHECK-NEXT: dir_index: 0 CHECK: 0x0000000100000f50 19 0 1 0 0 is_stmt CHECK: 0x0000000100000f54 20 0 1 0 0 is_stmt prologue_end CHECK: 0x0000000100000f63 15 0 1 0 0 is_stmt CHECK: 0x0000000100000f72 20 0 1 0 0 is_stmt CHECK: 0x0000000100000f89 20 0 1 0 0 is_stmt end_sequence -CHECK: Dir Mod Time File Len File Name -CHECK-NEXT: ---- ---------- ---------- --------------------------- -CHECK-NEXT: file_names[ 1] 0 0x00000000 0x00000000 "basic3.c" +CHECK: file_names[ 1]: +CHECK-NEXT: name: "basic3.c" +CHECK-NEXT: dir_index: 0 CHECK: 0x0000000100000f90 16 0 1 0 0 is_stmt CHECK: 0x0000000100000f94 12 0 1 0 0 is_stmt prologue_end CHECK: 0x0000000100000f9a 17 0 1 0 0 is_stmt Index: test/tools/llvm-objdump/embedded-source.test =================================================================== --- /dev/null +++ test/tools/llvm-objdump/embedded-source.test @@ -0,0 +1,22 @@ +; RUN: llvm-objdump -disassemble -line-numbers %p/Inputs/embedded-source | FileCheck --check-prefix=LINE %s +; RUN: llvm-objdump -disassemble -source %p/Inputs/embedded-source | FileCheck --check-prefix=SOURCE %s + +; LINE: main: +; LINE-NEXT: ; {{.*}}embedded-source.c:1 +; LINE-NEXT: pushq %rbp +; LINE: ; {{.*}}embedded-source.c:2 +; LINE-NEXT: movl $2 +; LINE: ; {{.*}}embedded-source.c:3 +; LINE: addl $1 +; LINE: ; {{.*}}embedded-source.c:4 +; LINE: retq + +; SOURCE: main: +; SOURCE-NEXT: ; int main(int argc, char *argv[]) { +; SOURCE-NEXT: pushq %rbp +; SOURCE: ; int i = 2; +; SOURCE-NEXT: movl $2 +; SOURCE: ; i += 1; +; SOURCE: addl $1 +; SOURCE: ; return i; +; SOURCE: retq Index: tools/llvm-objdump/llvm-objdump.cpp =================================================================== --- tools/llvm-objdump/llvm-objdump.cpp +++ tools/llvm-objdump/llvm-objdump.cpp @@ -408,7 +408,7 @@ std::unordered_map> LineCache; private: - bool cacheSource(const std::string& File); + bool cacheSource(const DILineInfo& LineInfoFile); public: SourcePrinter() = default; @@ -423,23 +423,29 @@ StringRef Delimiter = "; "); }; -bool SourcePrinter::cacheSource(const std::string& File) { - auto BufferOrError = MemoryBuffer::getFile(File); - if (!BufferOrError) - return false; +bool SourcePrinter::cacheSource(const DILineInfo &LineInfo) { + std::unique_ptr Buffer; + if (LineInfo.Source) { + Buffer = MemoryBuffer::getMemBuffer(*LineInfo.Source); + } else { + auto BufferOrError = MemoryBuffer::getFile(LineInfo.FileName); + if (!BufferOrError) + return false; + Buffer = std::move(*BufferOrError); + } // Chomp the file to get lines - size_t BufferSize = (*BufferOrError)->getBufferSize(); - const char *BufferStart = (*BufferOrError)->getBufferStart(); + size_t BufferSize = Buffer->getBufferSize(); + const char *BufferStart = Buffer->getBufferStart(); for (const char *Start = BufferStart, *End = BufferStart; End < BufferStart + BufferSize; End++) if (*End == '\n' || End == BufferStart + BufferSize - 1 || (*End == '\r' && *(End + 1) == '\n')) { - LineCache[File].push_back(StringRef(Start, End - Start)); + LineCache[LineInfo.FileName].push_back(StringRef(Start, End - Start)); if (*End == '\r') End++; Start = End + 1; } - SourceCache[File] = std::move(*BufferOrError); + SourceCache[LineInfo.FileName] = std::move(Buffer); return true; } @@ -463,7 +469,7 @@ OS << Delimiter << LineInfo.FileName << ":" << LineInfo.Line << "\n"; if (PrintSource) { if (SourceCache.find(LineInfo.FileName) == SourceCache.end()) - if (!cacheSource(LineInfo.FileName)) + if (!cacheSource(LineInfo)) return; auto FileBuffer = SourceCache.find(LineInfo.FileName); if (FileBuffer != SourceCache.end()) { Index: unittests/IR/MetadataTest.cpp =================================================================== --- unittests/IR/MetadataTest.cpp +++ unittests/IR/MetadataTest.cpp @@ -1450,19 +1450,24 @@ DIFile::ChecksumKind CSKind = DIFile::ChecksumKind::CSK_MD5; StringRef ChecksumString = "000102030405060708090a0b0c0d0e0f"; DIFile::ChecksumInfo Checksum(CSKind, ChecksumString); - auto *N = DIFile::get(Context, Filename, Directory, Checksum); + StringRef Source = "source"; + auto *N = DIFile::get(Context, Filename, Directory, Checksum, Source); EXPECT_EQ(dwarf::DW_TAG_file_type, N->getTag()); EXPECT_EQ(Filename, N->getFilename()); EXPECT_EQ(Directory, N->getDirectory()); EXPECT_EQ(Checksum, N->getChecksum()); - EXPECT_EQ(N, DIFile::get(Context, Filename, Directory, Checksum)); + EXPECT_EQ(Source, N->getSource()); + EXPECT_EQ(N, DIFile::get(Context, Filename, Directory, Checksum, Source)); - EXPECT_NE(N, DIFile::get(Context, "other", Directory, Checksum)); - EXPECT_NE(N, DIFile::get(Context, Filename, "other", Checksum)); + EXPECT_NE(N, DIFile::get(Context, "other", Directory, Checksum, Source)); + EXPECT_NE(N, DIFile::get(Context, Filename, "other", Checksum, Source)); DIFile::ChecksumInfo OtherChecksum(DIFile::ChecksumKind::CSK_SHA1, ChecksumString); EXPECT_NE( N, DIFile::get(Context, Filename, Directory, OtherChecksum)); + StringRef OtherSource = "other"; + EXPECT_NE(N, DIFile::get(Context, Filename, Directory, Checksum, OtherSource)); + EXPECT_NE(N, DIFile::get(Context, Filename, Directory, Checksum)); EXPECT_NE(N, DIFile::get(Context, Filename, Directory)); TempDIFile Temp = N->clone();