Revert "Reapply "[DWARFv5] Emit file 0 to the line table.""

This reverts commit r328676.

Commit r328676 broke the -no-integrated-as flag necessary to build Linux kernel with Clang:

$ cat t.c
void foo() {}
$ clang -no-integrated-as   -c  t.c -g
/tmp/t-dcdec5.s: Assembler messages:
/tmp/t-dcdec5.s:8: Error: file number less than one
clang-7.0: error: assembler command failed with exit code 1 (use -v to see invocation)

llvm-svn: 328699
This commit is contained in:
Alexander Potapenko 2018-03-28 12:36:46 +00:00
parent 5076b98fb9
commit 202f809437
20 changed files with 133 additions and 256 deletions

View File

@ -537,13 +537,8 @@ namespace llvm {
DwarfCompileUnitID = CUIndex; DwarfCompileUnitID = CUIndex;
} }
/// Specifies the "root" file and directory of the compilation unit. void setMCLineTableCompilationDir(unsigned CUID, StringRef CompilationDir) {
/// These are "file 0" and "directory 0" in DWARF v5. getMCDwarfLineTable(CUID).setCompilationDir(CompilationDir);
void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir,
StringRef Filename, MD5::MD5Result *Checksum,
Optional<StringRef> Source) {
getMCDwarfLineTable(CUID).setRootFile(CompilationDir, Filename, Checksum,
Source);
} }
/// Saves the information from the currently parsed dwarf .loc directive /// Saves the information from the currently parsed dwarf .loc directive

View File

@ -214,7 +214,6 @@ struct MCDwarfLineTableHeader {
SmallVector<MCDwarfFile, 3> MCDwarfFiles; SmallVector<MCDwarfFile, 3> MCDwarfFiles;
StringMap<unsigned> SourceIdMap; StringMap<unsigned> SourceIdMap;
StringRef CompilationDir; StringRef CompilationDir;
MCDwarfFile RootFile;
bool HasMD5 = false; bool HasMD5 = false;
bool HasSource = false; bool HasSource = false;
@ -242,17 +241,8 @@ class MCDwarfDwoLineTable {
MCDwarfLineTableHeader Header; MCDwarfLineTableHeader Header;
public: public:
void maybeSetRootFile(StringRef Directory, StringRef FileName, void setCompilationDir(StringRef CompilationDir) {
MD5::MD5Result *Checksum, Optional<StringRef> Source) { Header.CompilationDir = CompilationDir;
if (!Header.RootFile.Name.empty())
return;
Header.CompilationDir = Directory;
Header.RootFile.Name = FileName;
Header.RootFile.DirIndex = 0;
Header.RootFile.Checksum = Checksum;
Header.RootFile.Source = Source;
Header.HasMD5 = (Checksum != nullptr);
Header.HasSource = Source.hasValue();
} }
unsigned getFile(StringRef Directory, StringRef FileName, unsigned getFile(StringRef Directory, StringRef FileName,
@ -287,17 +277,6 @@ public:
FileNumber)); FileNumber));
} }
void setRootFile(StringRef Directory, StringRef FileName,
MD5::MD5Result *Checksum, Optional<StringRef> Source) {
Header.CompilationDir = Directory;
Header.RootFile.Name = FileName;
Header.RootFile.DirIndex = 0;
Header.RootFile.Checksum = Checksum;
Header.RootFile.Source = Source;
Header.HasMD5 = (Checksum != nullptr);
Header.HasSource = Source.hasValue();
}
MCSymbol *getLabel() const { MCSymbol *getLabel() const {
return Header.Label; return Header.Label;
} }
@ -306,6 +285,10 @@ public:
Header.Label = Label; Header.Label = Label;
} }
void setCompilationDir(StringRef CompilationDir) {
Header.CompilationDir = CompilationDir;
}
const SmallVectorImpl<std::string> &getMCDwarfDirs() const { const SmallVectorImpl<std::string> &getMCDwarfDirs() const {
return Header.MCDwarfDirs; return Header.MCDwarfDirs;
} }

View File

@ -775,12 +775,6 @@ public:
MD5::MD5Result *Checksum = nullptr, Optional<StringRef> Source = None, MD5::MD5Result *Checksum = nullptr, Optional<StringRef> Source = None,
unsigned CUID = 0); unsigned CUID = 0);
/// Specify the "root" file of the compilation, using the ".file 0" extension.
virtual void emitDwarfFile0Directive(StringRef Directory, StringRef Filename,
MD5::MD5Result *Checksum,
Optional<StringRef> Source,
unsigned CUID = 0);
/// \brief This implements the DWARF2 '.loc fileno lineno ...' assembler /// \brief This implements the DWARF2 '.loc fileno lineno ...' assembler
/// directive. /// directive.
virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,

View File

@ -499,9 +499,8 @@ DwarfDebug::getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit) {
// explicitly describe the directory of all files, never relying on the // explicitly describe the directory of all files, never relying on the
// compilation directory. // compilation directory.
if (!Asm->OutStreamer->hasRawTextSupport() || SingleCU) if (!Asm->OutStreamer->hasRawTextSupport() || SingleCU)
Asm->OutStreamer->emitDwarfFile0Directive( Asm->OutStreamer->getContext().setMCLineTableCompilationDir(
CompilationDir, FN, NewCU.getMD5AsBytes(DIUnit->getFile()), NewCU.getUniqueID(), CompilationDir);
DIUnit->getSource(), NewCU.getUniqueID());
StringRef Producer = DIUnit->getProducer(); StringRef Producer = DIUnit->getProducer();
StringRef Flags = DIUnit->getFlags(); StringRef Flags = DIUnit->getFlags();
@ -2149,10 +2148,8 @@ void DwarfDebug::emitDebugStrDWO() {
MCDwarfDwoLineTable *DwarfDebug::getDwoLineTable(const DwarfCompileUnit &CU) { MCDwarfDwoLineTable *DwarfDebug::getDwoLineTable(const DwarfCompileUnit &CU) {
if (!useSplitDwarf()) if (!useSplitDwarf())
return nullptr; return nullptr;
const DICompileUnit *DIUnit = CU.getCUNode(); if (SingleCU)
SplitTypeUnitFileTable.maybeSetRootFile( SplitTypeUnitFileTable.setCompilationDir(CU.getCUNode()->getDirectory());
DIUnit->getDirectory(), DIUnit->getFilename(),
CU.getMD5AsBytes(DIUnit->getFile()), DIUnit->getSource());
return &SplitTypeUnitFileTable; return &SplitTypeUnitFileTable;
} }

View File

@ -282,7 +282,7 @@ void DwarfUnit::addSectionOffset(DIE &Die, dwarf::Attribute Attribute,
addUInt(Die, Attribute, dwarf::DW_FORM_data4, Integer); addUInt(Die, Attribute, dwarf::DW_FORM_data4, Integer);
} }
MD5::MD5Result *DwarfUnit::getMD5AsBytes(const DIFile *File) const { MD5::MD5Result *DwarfUnit::getMD5AsBytes(const DIFile *File) {
assert(File); assert(File);
Optional<DIFile::ChecksumInfo<StringRef>> Checksum = File->getChecksum(); Optional<DIFile::ChecksumInfo<StringRef>> Checksum = File->getChecksum();
if (!Checksum || Checksum->Kind != DIFile::CSK_MD5) if (!Checksum || Checksum->Kind != DIFile::CSK_MD5)

View File

@ -306,10 +306,6 @@ public:
const MCSymbol *Label, const MCSymbol *Label,
const MCSymbol *Sec); const MCSymbol *Sec);
/// If the \p File has an MD5 checksum, return it as an MD5Result
/// allocated in the MCContext.
MD5::MD5Result *getMD5AsBytes(const DIFile *File) const;
protected: protected:
~DwarfUnit(); ~DwarfUnit();
@ -320,6 +316,10 @@ protected:
/// create a new ID and insert it in the line table. /// create a new ID and insert it in the line table.
virtual unsigned getOrCreateSourceID(const DIFile *File) = 0; virtual unsigned getOrCreateSourceID(const DIFile *File) = 0;
/// If the \p File has an MD5 checksum, return it as an MD5Result
/// allocated in the MCContext.
MD5::MD5Result *getMD5AsBytes(const DIFile *File);
/// Look in the DwarfDebug map for the MDNode that corresponds to the /// Look in the DwarfDebug map for the MDNode that corresponds to the
/// reference. /// reference.
template <typename T> T *resolve(TypedDINodeRef<T> Ref) const { template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {

View File

@ -219,10 +219,6 @@ public:
MD5::MD5Result *Checksum = 0, MD5::MD5Result *Checksum = 0,
Optional<StringRef> Source = None, Optional<StringRef> Source = None,
unsigned CUID = 0) override; unsigned CUID = 0) override;
void emitDwarfFile0Directive(StringRef Directory, StringRef Filename,
MD5::MD5Result *Checksum,
Optional<StringRef> Source,
unsigned CUID = 0) override;
void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
unsigned Column, unsigned Flags, unsigned Column, unsigned Flags,
unsigned Isa, unsigned Discriminator, unsigned Isa, unsigned Discriminator,
@ -1081,10 +1077,21 @@ void MCAsmStreamer::EmitFileDirective(StringRef Filename) {
EmitEOL(); EmitEOL();
} }
void printDwarfFileDirective(unsigned FileNo, StringRef Directory, Expected<unsigned> MCAsmStreamer::tryEmitDwarfFileDirective(
StringRef Filename, MD5::MD5Result *Checksum, unsigned FileNo, StringRef Directory, StringRef Filename,
Optional<StringRef> Source, bool UseDwarfDirectory, MD5::MD5Result *Checksum, Optional<StringRef> Source, unsigned CUID) {
raw_svector_ostream &OS) { assert(CUID == 0);
MCDwarfLineTable &Table = getContext().getMCDwarfLineTable(CUID);
unsigned NumFiles = Table.getMCDwarfFiles().size();
Expected<unsigned> FileNoOrErr =
Table.tryGetFile(Directory, Filename, Checksum, Source, FileNo);
if (!FileNoOrErr)
return FileNoOrErr.takeError();
FileNo = FileNoOrErr.get();
if (NumFiles == Table.getMCDwarfFiles().size())
return FileNo;
SmallString<128> FullPathName; SmallString<128> FullPathName;
if (!UseDwarfDirectory && !Directory.empty()) { if (!UseDwarfDirectory && !Directory.empty()) {
@ -1098,68 +1105,31 @@ void printDwarfFileDirective(unsigned FileNo, StringRef Directory,
} }
} }
OS << "\t.file\t" << FileNo << ' '; SmallString<128> Str;
raw_svector_ostream OS1(Str);
OS1 << "\t.file\t" << FileNo << ' ';
if (!Directory.empty()) { if (!Directory.empty()) {
PrintQuotedString(Directory, OS); PrintQuotedString(Directory, OS1);
OS << ' '; OS1 << ' ';
} }
PrintQuotedString(Filename, OS); PrintQuotedString(Filename, OS1);
if (Checksum) { if (Checksum) {
OS << " md5 "; OS1 << " md5 ";
PrintQuotedString(Checksum->digest(), OS); PrintQuotedString(Checksum->digest(), OS1);
} }
if (Source) { if (Source) {
OS << " source "; OS1 << " source ";
PrintQuotedString(*Source, OS); PrintQuotedString(*Source, OS1);
} }
} if (MCTargetStreamer *TS = getTargetStreamer()) {
Expected<unsigned> MCAsmStreamer::tryEmitDwarfFileDirective(
unsigned FileNo, StringRef Directory, StringRef Filename,
MD5::MD5Result *Checksum, Optional<StringRef> Source, unsigned CUID) {
assert(CUID == 0 && "multiple CUs not supported by MCAsmStreamer");
MCDwarfLineTable &Table = getContext().getMCDwarfLineTable(CUID);
unsigned NumFiles = Table.getMCDwarfFiles().size();
Expected<unsigned> FileNoOrErr =
Table.tryGetFile(Directory, Filename, Checksum, Source, FileNo);
if (!FileNoOrErr)
return FileNoOrErr.takeError();
FileNo = FileNoOrErr.get();
if (NumFiles == Table.getMCDwarfFiles().size())
return FileNo;
SmallString<128> Str;
raw_svector_ostream OS1(Str);
printDwarfFileDirective(FileNo, Directory, Filename, Checksum, Source,
UseDwarfDirectory, OS1);
if (MCTargetStreamer *TS = getTargetStreamer())
TS->emitDwarfFileDirective(OS1.str()); TS->emitDwarfFileDirective(OS1.str());
else } else {
EmitRawText(OS1.str()); EmitRawText(OS1.str());
}
return FileNo; return FileNo;
} }
void MCAsmStreamer::emitDwarfFile0Directive(StringRef Directory,
StringRef Filename,
MD5::MD5Result *Checksum,
Optional<StringRef> Source,
unsigned CUID) {
assert(CUID == 0);
SmallString<128> Str;
raw_svector_ostream OS1(Str);
printDwarfFileDirective(0, Directory, Filename, Checksum, Source,
UseDwarfDirectory, OS1);
if (MCTargetStreamer *TS = getTargetStreamer())
TS->emitDwarfFileDirective(OS1.str());
else
EmitRawText(OS1.str());
}
void MCAsmStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line, void MCAsmStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
unsigned Column, unsigned Flags, unsigned Column, unsigned Flags,
unsigned Isa, unsigned Isa,

View File

@ -349,34 +349,6 @@ void MCDwarfLineTableHeader::emitV2FileDirTables(MCStreamer *MCOS) const {
MCOS->EmitIntValue(0, 1); // Terminate the file list. MCOS->EmitIntValue(0, 1); // Terminate the file list.
} }
static void emitOneV5FileEntry(MCStreamer *MCOS, const MCDwarfFile &DwarfFile,
bool HasMD5, bool HasSource,
Optional<MCDwarfLineStr> &LineStr) {
assert(!DwarfFile.Name.empty());
if (LineStr)
LineStr->emitRef(MCOS, DwarfFile.Name);
else {
MCOS->EmitBytes(DwarfFile.Name); // FileName and...
MCOS->EmitBytes(StringRef("\0", 1)); // its null terminator.
}
MCOS->EmitULEB128IntValue(DwarfFile.DirIndex); // Directory number.
if (HasMD5) {
MD5::MD5Result *Cksum = DwarfFile.Checksum;
MCOS->EmitBinaryData(
StringRef(reinterpret_cast<const char *>(Cksum->Bytes.data()),
Cksum->Bytes.size()));
}
if (HasSource) {
if (LineStr)
LineStr->emitRef(MCOS, DwarfFile.Source.getValueOr(StringRef()));
else {
MCOS->EmitBytes(
DwarfFile.Source.getValueOr(StringRef())); // Source and...
MCOS->EmitBytes(StringRef("\0", 1)); // its null terminator.
}
}
}
void MCDwarfLineTableHeader::emitV5FileDirTables( void MCDwarfLineTableHeader::emitV5FileDirTables(
MCStreamer *MCOS, Optional<MCDwarfLineStr> &LineStr) const { MCStreamer *MCOS, Optional<MCDwarfLineStr> &LineStr) const {
// The directory format, which is just a list of the directory paths. In a // The directory format, which is just a list of the directory paths. In a
@ -425,12 +397,33 @@ void MCDwarfLineTableHeader::emitV5FileDirTables(
MCOS->EmitULEB128IntValue(LineStr ? dwarf::DW_FORM_line_strp MCOS->EmitULEB128IntValue(LineStr ? dwarf::DW_FORM_line_strp
: dwarf::DW_FORM_string); : dwarf::DW_FORM_string);
} }
// Then the counted list of files. The root file is file #0, then emit the // Then the list of file names. These start at 1.
// files as provide by .file directives. MCOS->EmitULEB128IntValue(MCDwarfFiles.size() - 1);
MCOS->EmitULEB128IntValue(MCDwarfFiles.size()); for (unsigned i = 1; i < MCDwarfFiles.size(); ++i) {
emitOneV5FileEntry(MCOS, RootFile, HasMD5, HasSource, LineStr); assert(!MCDwarfFiles[i].Name.empty());
for (unsigned i = 1; i < MCDwarfFiles.size(); ++i) if (LineStr)
emitOneV5FileEntry(MCOS, MCDwarfFiles[i], HasMD5, HasSource, LineStr); LineStr->emitRef(MCOS, MCDwarfFiles[i].Name);
else {
MCOS->EmitBytes(MCDwarfFiles[i].Name); // FileName and...
MCOS->EmitBytes(StringRef("\0", 1)); // its null terminator.
}
MCOS->EmitULEB128IntValue(MCDwarfFiles[i].DirIndex); // Directory number.
if (HasMD5) {
MD5::MD5Result *Cksum = MCDwarfFiles[i].Checksum;
MCOS->EmitBinaryData(
StringRef(reinterpret_cast<const char *>(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.
}
}
}
} }
std::pair<MCSymbol *, MCSymbol *> std::pair<MCSymbol *, MCSymbol *>

View File

@ -3276,8 +3276,8 @@ bool AsmParser::parseDirectiveFile(SMLoc DirectiveLoc) {
FileNumber = getTok().getIntVal(); FileNumber = getTok().getIntVal();
Lex(); Lex();
if (FileNumber < 0) if (FileNumber < 1)
return TokError("negative file number"); return TokError("file number less than one");
} }
std::string Path = getTok().getString(); std::string Path = getTok().getString();
@ -3356,15 +3356,11 @@ bool AsmParser::parseDirectiveFile(SMLoc DirectiveLoc) {
memcpy(SourceBuf, SourceString.data(), SourceString.size()); memcpy(SourceBuf, SourceString.data(), SourceString.size());
Source = StringRef(SourceBuf, SourceString.size()); Source = StringRef(SourceBuf, SourceString.size());
} }
if (FileNumber == 0) Expected<unsigned> FileNumOrErr = getStreamer().tryEmitDwarfFileDirective(
getStreamer().emitDwarfFile0Directive(Directory, Filename, CKMem, Source); FileNumber, Directory, Filename, CKMem, Source);
else { if (!FileNumOrErr)
Expected<unsigned> FileNumOrErr = getStreamer().tryEmitDwarfFileDirective( return Error(DirectiveLoc, toString(FileNumOrErr.takeError()));
FileNumber, Directory, Filename, CKMem, Source); FileNumber = FileNumOrErr.get();
if (!FileNumOrErr)
return Error(DirectiveLoc, toString(FileNumOrErr.takeError()));
FileNumber = FileNumOrErr.get();
}
} }
return false; return false;

View File

@ -199,15 +199,6 @@ MCStreamer::tryEmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
Source, CUID); Source, CUID);
} }
void MCStreamer::emitDwarfFile0Directive(StringRef Directory,
StringRef Filename,
MD5::MD5Result *Checksum,
Optional<StringRef> Source,
unsigned CUID) {
getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
Source);
}
void MCStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line, void MCStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
unsigned Column, unsigned Flags, unsigned Column, unsigned Flags,
unsigned Isa, unsigned Isa,

View File

@ -8,25 +8,28 @@
; RUN: %llc_dwarf -dwarf-version 4 -filetype=asm -o - %s | FileCheck %s --check-prefix=ASM ; 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 5 -filetype=asm -o - %s | FileCheck %s --check-prefix=ASM
; RUN: %llc_dwarf -dwarf-version 4 -filetype=obj -o %t4.o %s ; RUN: %llc_dwarf -dwarf-version 4 -filetype=obj -o %t4.o %s
; RUN: llvm-dwarfdump -debug-line %t4.o | FileCheck %s --check-prefix=OBJ ; 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: %llc_dwarf -dwarf-version 5 -filetype=obj -o %t5.o %s
; RUN: llvm-dwarfdump -debug-line %t5.o | FileCheck %s --check-prefixes=OBJ,OBJ-5 ; RUN: llvm-dwarfdump -debug-line %t5.o | FileCheck %s --check-prefix=OBJ-5
; ASM: .file 0 "[[COMPDIR:.*]]{{[/\\]}}t.c" md5 "00000000000000000000000000000000" ; FIXME: Need to convey the MD5 for the primary source file.
; ASM: .file 1 "[[COMPDIR]]{{[/\\]}}t1.h" md5 "11111111111111111111111111111111" ; ASM: .file 1 ".{{/|\\\\}}t1.h" md5 "11111111111111111111111111111111"
; ASM: .file 2 "[[COMPDIR]]{{[/\\]}}t2.h" md5 "22222222222222222222222222222222" ; ASM: .file 2 ".{{/|\\\\}}t2.h" md5 "22222222222222222222222222222222"
; 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: file_names[ 0]:
; OBJ-5-NEXT: name: "t.c" ; OBJ-5-NEXT: name: "t1.h"
; OBJ-5-NEXT: dir_index: 0 ; OBJ-5-NEXT: dir_index: 1
; OBJ-5-NEXT: md5_checksum: 00000000000000000000000000000000
; OBJ: file_names[ 1]:
; OBJ-NEXT: name: "t1.h"
; OBJ-NEXT: dir_index: 0
; OBJ-5-NEXT: md5_checksum: 11111111111111111111111111111111 ; OBJ-5-NEXT: md5_checksum: 11111111111111111111111111111111
; OBJ: file_names[ 2]: ; OBJ-5: file_names[ 1]:
; OBJ-NEXT: name: "t2.h" ; OBJ-5-NEXT: name: "t2.h"
; OBJ-NEXT: dir_index: 0 ; OBJ-5-NEXT: dir_index: 1
; OBJ-5-NEXT: md5_checksum: 22222222222222222222222222222222 ; OBJ-5-NEXT: md5_checksum: 22222222222222222222222222222222
; ModuleID = 't.c' ; ModuleID = 't.c'
@ -47,9 +50,9 @@ source_filename = "t.c"
!5 = !{!0, !6} !5 = !{!0, !6}
!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
!7 = distinct !DIGlobalVariable(name: "t2", scope: !2, file: !8, line: 1, type: !9, isLocal: false, isDefinition: true) !7 = distinct !DIGlobalVariable(name: "t2", scope: !2, file: !8, line: 1, type: !9, isLocal: false, isDefinition: true)
!8 = !DIFile(filename: "t2.h", directory: "/home/probinson/projects/scratch", checksumkind: CSK_MD5, checksum: "22222222222222222222222222222222") !8 = !DIFile(filename: "./t2.h", directory: "/home/probinson/projects/scratch", checksumkind: CSK_MD5, checksum: "22222222222222222222222222222222")
!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!10 = !DIFile(filename: "t1.h", directory: "/home/probinson/projects/scratch", checksumkind: CSK_MD5, checksum: "11111111111111111111111111111111") !10 = !DIFile(filename: "./t1.h", directory: "/home/probinson/projects/scratch", checksumkind: CSK_MD5, checksum: "11111111111111111111111111111111")
!11 = !{i32 2, !"Dwarf Version", i32 4} !11 = !{i32 2, !"Dwarf Version", i32 4}
!12 = !{i32 2, !"Debug Info Version", i32 3} !12 = !{i32 2, !"Debug Info Version", i32 3}
!13 = !{i32 1, !"wchar_size", i32 4} !13 = !{i32 1, !"wchar_size", i32 4}

View File

@ -8,27 +8,30 @@
; RUN: %llc_dwarf -dwarf-version 4 -filetype=asm -o - %s | FileCheck %s --check-prefix=ASM ; 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 5 -filetype=asm -o - %s | FileCheck %s --check-prefix=ASM
; RUN: %llc_dwarf -dwarf-version 4 -filetype=obj -o %t4.o %s ; RUN: %llc_dwarf -dwarf-version 4 -filetype=obj -o %t4.o %s
; RUN: llvm-dwarfdump -debug-line %t4.o | FileCheck %s --check-prefixes=OBJ,OBJ-4 ; 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: %llc_dwarf -dwarf-version 5 -filetype=obj -o %t5.o %s
; RUN: llvm-dwarfdump -debug-line %t5.o | FileCheck %s --check-prefixes=OBJ,OBJ-5 ; RUN: llvm-dwarfdump -debug-line %t5.o | FileCheck %s --check-prefix=OBJ-5
; ASM: .file 0 "[[COMPDIR:.*]]{{[/\\]}}t.c" source "00000000000000000000000000000000" ; FIXME: Need to convey the source for the primary source file.
; ASM: .file 1 "[[COMPDIR]]{{[/\\]}}t1.h" source "11111111111111111111111111111111" ; ASM: .file 1 ".{{/|\\\\}}t1.h" source "11111111111111111111111111111111"
; ASM: .file 2 "[[COMPDIR]]{{[/\\]}}t2.h" source "22222222222222222222222222222222" ; 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: file_names[ 0]:
; OBJ-5-NEXT: name: "t.c" ; OBJ-5-NEXT: name: "t1.h"
; OBJ-5-NEXT: dir_index: 0 ; OBJ-5-NEXT: dir_index: 1
; OBJ-5-NEXT: source: "00000000000000000000000000000000"
; OBJ: file_names[ 1]:
; OBJ-NEXT: name: "t1.h"
; OBJ-NEXT: dir_index: 0
; OBJ-4-NOT: 11111111111111111111111111111111
; OBJ-5-NEXT: source: "11111111111111111111111111111111" ; OBJ-5-NEXT: source: "11111111111111111111111111111111"
; OBJ: file_names[ 2]: ; OBJ-5: file_names[ 1]:
; OBJ-NEXT: name: "t2.h" ; OBJ-5-NEXT: name: "t2.h"
; OBJ-NEXT: dir_index: 0 ; OBJ-5-NEXT: dir_index: 1
; OBJ-4-NOT: 22222222222222222222222222222222
; OBJ-5-NEXT: source: "22222222222222222222222222222222" ; OBJ-5-NEXT: source: "22222222222222222222222222222222"
; ModuleID = 't.c' ; ModuleID = 't.c'
@ -49,9 +52,9 @@ source_filename = "t.c"
!5 = !{!0, !6} !5 = !{!0, !6}
!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
!7 = distinct !DIGlobalVariable(name: "t2", scope: !2, file: !8, line: 1, type: !9, isLocal: false, isDefinition: true) !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") !8 = !DIFile(filename: "./t2.h", directory: "/test", source: "22222222222222222222222222222222")
!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!10 = !DIFile(filename: "t1.h", directory: "/test", source: "11111111111111111111111111111111") !10 = !DIFile(filename: "./t1.h", directory: "/test", source: "11111111111111111111111111111111")
!11 = !{i32 2, !"Dwarf Version", i32 4} !11 = !{i32 2, !"Dwarf Version", i32 4}
!12 = !{i32 2, !"Debug Info Version", i32 3} !12 = !{i32 2, !"Debug Info Version", i32 3}
!13 = !{i32 1, !"wchar_size", i32 4} !13 = !{i32 1, !"wchar_size", i32 4}

View File

@ -2,7 +2,7 @@
; Verify that the file name is relative to the directory. ; Verify that the file name is relative to the directory.
; rdar://problem/8884898 ; rdar://problem/8884898
; CHECK: file 1 "/Users/manav/one/two" "simple.c" ; CHECK: file 1 "simple.c"
declare i32 @printf(i8*, ...) nounwind declare i32 @printf(i8*, ...) nounwind

View File

@ -22,7 +22,7 @@
; CHECK: .file 2 "B.asm" ; CHECK: .file 2 "B.asm"
; CHECK: .loc 1 111 ; CHECK: .loc 1 111
; CHECK: .loc 2 222 ; CHECK: .loc 2 222
; CHECK: .file 3 "{{.*[/\\]}}test.c" ; CHECK: .file 3 "test.c"
; CHECK: .loc 3 14 0 ; CHECK: .loc 3 14 0
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"

View File

@ -54,9 +54,9 @@ b:
// DWARF-DL: .debug_line contents: // DWARF-DL: .debug_line contents:
// DWARF-DL: version: [[DWVER]] // DWARF-DL: version: [[DWVER]]
// DWARF-DL-5: address_size: 4 // DWARF-DL-5: address_size: 4
// DWARF-DL-5: include_directories[ 0] = "/tmp" // DWARF-DL-5: include_directories[ 0] = ""
// DWARF-DL: file_names[ [[DWFILE]]]: // DWARF-DL: file_names[ [[DWFILE]]]:
// DWARF-DL: name: "{{(<stdin>|-)}}" // DWARF-DL: name: "<stdin>"
// DWARF-DL: 0x0000000000000000 17 0 1 0 0 is_stmt // 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: 0x0000000000000004 17 0 1 0 0 is_stmt end_sequence
// DWARF-DL-NEXT: 0x0000000000000000 21 0 1 0 0 is_stmt // DWARF-DL-NEXT: 0x0000000000000000 21 0 1 0 0 is_stmt

View File

@ -11,32 +11,25 @@
# CHECK: debug_line[0x00000000] # CHECK: debug_line[0x00000000]
# CHECK: version: 5 # CHECK: version: 5
# CHECK: include_directories[ 0] = .debug_line_str[0x[[DIR0:[0-9a-f]+]]] = "{{.+}}" # 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[ 1] = .debug_line_str[0x[[DIR1:[0-9a-f]+]]] = "dir1"
# CHECK: include_directories[ 2] = .debug_line_str[0x[[DIR2:[0-9a-f]+]]] = "dir2" # CHECK: include_directories[ 2] = .debug_line_str[0x[[DIR2:[0-9a-f]+]]] = "dir2"
# CHECK-NOT: include_directories # CHECK-NOT: include_directories
# CHECK: file_names[ 0]: # CHECK: file_names[ 0]:
# CHECK-NEXT: name: .debug_line_str[0x[[FILE0:[0-9a-f]+]]] = "{{.+}}"
# CHECK-NEXT: dir_index: 0
# CHECK-NEXT: md5_checksum:
# CHECK-NEXT: source: .debug_line_str[0x[[FILE0SRC:[0-9a-f]+]]] = ""
# CHECK: file_names[ 1]:
# CHECK-NEXT: name: .debug_line_str[0x[[FILE1:[0-9a-f]+]]] = "foo" # CHECK-NEXT: name: .debug_line_str[0x[[FILE1:[0-9a-f]+]]] = "foo"
# CHECK-NEXT: dir_index: 1 # CHECK-NEXT: dir_index: 1
# CHECK-NEXT: md5_checksum: ee87e05688663173cd6043a3a15bba6e # CHECK-NEXT: md5_checksum: ee87e05688663173cd6043a3a15bba6e
# CHECK-NEXT: source: .debug_line_str[0x[[FILE1SRC:[0-9a-f]+]]] = "void foo() {}" # CHECK-NEXT: source: .debug_line_str[0x[[FILE1SRC:[0-9a-f]+]]] = "void foo() {}"
# CHECK: file_names[ 2]: # CHECK: file_names[ 1]:
# CHECK-NEXT: name: .debug_line_str[0x[[FILE2:[0-9a-f]+]]] = "bar" # CHECK-NEXT: name: .debug_line_str[0x[[FILE2:[0-9a-f]+]]] = "bar"
# CHECK-NEXT: dir_index: 2 # CHECK-NEXT: dir_index: 2
# CHECK-NEXT: md5_checksum: 816225a0c90ca8948b70eb58be4d522f # CHECK-NEXT: md5_checksum: 816225a0c90ca8948b70eb58be4d522f
# CHECK-NEXT: source: .debug_line_str[0x[[FILE2SRC:[0-9a-f]+]]] = "void bar() {}" # CHECK-NEXT: source: .debug_line_str[0x[[FILE2SRC:[0-9a-f]+]]] = "void bar() {}"
# CHECK: .debug_line_str contents: # CHECK: .debug_line_str contents:
# CHECK-NEXT: 0x[[DIR0]]: "{{.+}}" # CHECK-NEXT: 0x[[DIR0]]: ""
# CHECK-NEXT: 0x[[DIR1]]: "dir1" # CHECK-NEXT: 0x[[DIR1]]: "dir1"
# CHECK-NEXT: 0x[[DIR2]]: "dir2" # CHECK-NEXT: 0x[[DIR2]]: "dir2"
# CHECK-NEXT: 0x[[FILE0]]: "{{.+}}"
# CHECK-NEXT: 0x[[FILE0SRC]]: ""
# CHECK-NEXT: 0x[[FILE1]]: "foo" # CHECK-NEXT: 0x[[FILE1]]: "foo"
# CHECK-NEXT: 0x[[FILE1SRC]]: "void foo() {}" # CHECK-NEXT: 0x[[FILE1SRC]]: "void foo() {}"
# CHECK-NEXT: 0x[[FILE2]]: "bar" # CHECK-NEXT: 0x[[FILE2]]: "bar"

View File

@ -1,4 +1,4 @@
// RUN: llvm-mc -triple x86_64-unknown-unknown -dwarf-version 5 -fdebug-compilation-dir=/tmp -filetype=obj %s -o - | llvm-dwarfdump --debug-line --debug-line-str -v - | FileCheck %s // 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" md5 "00112233445566778899aabbccddeeff" .file 1 "dir1/foo" md5 "00112233445566778899aabbccddeeff"
.file 2 "dir2" "bar" md5 "ffeeddccbbaa99887766554433221100" .file 2 "dir2" "bar" md5 "ffeeddccbbaa99887766554433221100"
@ -9,26 +9,22 @@
# CHECK: debug_line[0x00000000] # CHECK: debug_line[0x00000000]
# CHECK: version: 5 # CHECK: version: 5
# CHECK: include_directories[ 0] = .debug_line_str[0x[[DIR0:[0-9a-f]+]]] = "/tmp" # 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[ 1] = .debug_line_str[0x[[DIR1:[0-9a-f]+]]] = "dir1"
# CHECK: include_directories[ 2] = .debug_line_str[0x[[DIR2:[0-9a-f]+]]] = "dir2" # CHECK: include_directories[ 2] = .debug_line_str[0x[[DIR2:[0-9a-f]+]]] = "dir2"
# CHECK-NOT: include_directories # CHECK-NOT: include_directories
# CHECK: file_names[ 0]: # CHECK: file_names[ 0]:
# CHECK-NEXT: name: .debug_line_str[0x[[FILE0:[0-9a-f]+]]] = "{{.+}}"
# CHECK-NEXT: dir_index: 0
# CHECK: file_names[ 1]:
# CHECK-NEXT: name: .debug_line_str[0x[[FILE1:[0-9a-f]+]]] = "foo" # CHECK-NEXT: name: .debug_line_str[0x[[FILE1:[0-9a-f]+]]] = "foo"
# CHECK-NEXT: dir_index: 1 # CHECK-NEXT: dir_index: 1
# CHECK-NEXT: md5_checksum: 00112233445566778899aabbccddeeff # CHECK-NEXT: md5_checksum: 00112233445566778899aabbccddeeff
# CHECK: file_names[ 2]: # CHECK: file_names[ 1]:
# CHECK-NEXT: name: .debug_line_str[0x[[FILE2:[0-9a-f]+]]] = "bar" # CHECK-NEXT: name: .debug_line_str[0x[[FILE2:[0-9a-f]+]]] = "bar"
# CHECK-NEXT: dir_index: 2 # CHECK-NEXT: dir_index: 2
# CHECK-NEXT: md5_checksum: ffeeddccbbaa99887766554433221100 # CHECK-NEXT: md5_checksum: ffeeddccbbaa99887766554433221100
# CHECK: .debug_line_str contents: # CHECK: .debug_line_str contents:
# CHECK-NEXT: 0x[[DIR0]]: "/tmp" # CHECK-NEXT: 0x[[DIR0]]: ""
# CHECK-NEXT: 0x[[DIR1]]: "dir1" # CHECK-NEXT: 0x[[DIR1]]: "dir1"
# CHECK-NEXT: 0x[[DIR2]]: "dir2" # CHECK-NEXT: 0x[[DIR2]]: "dir2"
# CHECK-NEXT: 0x[[FILE0]]: "{{.+}}"
# CHECK-NEXT: 0x[[FILE1]]: "foo" # CHECK-NEXT: 0x[[FILE1]]: "foo"
# CHECK-NEXT: 0x[[FILE2]]: "bar" # CHECK-NEXT: 0x[[FILE2]]: "bar"

View File

@ -9,29 +9,23 @@
# CHECK: debug_line[0x00000000] # CHECK: debug_line[0x00000000]
# CHECK: version: 5 # CHECK: version: 5
# CHECK: include_directories[ 0] = .debug_line_str[0x[[DIR0:[0-9a-f]+]]] = "{{.+}}" # 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[ 1] = .debug_line_str[0x[[DIR1:[0-9a-f]+]]] = "dir1"
# CHECK: include_directories[ 2] = .debug_line_str[0x[[DIR2:[0-9a-f]+]]] = "dir2" # CHECK: include_directories[ 2] = .debug_line_str[0x[[DIR2:[0-9a-f]+]]] = "dir2"
# CHECK-NOT: include_directories # CHECK-NOT: include_directories
# CHECK: file_names[ 0]: # CHECK: file_names[ 0]:
# CHECK-NEXT: name: .debug_line_str[0x[[FILE0:[0-9a-f]+]]] = "{{.+}}"
# CHECK-NEXT: dir_index: 0
# CHECK-NEXT: source: .debug_line_str[0x[[FILE0SRC:[0-9a-f]+]]] = ""
# CHECK: file_names[ 1]:
# CHECK-NEXT: name: .debug_line_str[0x[[FILE1:[0-9a-f]+]]] = "foo" # CHECK-NEXT: name: .debug_line_str[0x[[FILE1:[0-9a-f]+]]] = "foo"
# CHECK-NEXT: dir_index: 1 # CHECK-NEXT: dir_index: 1
# CHECK-NEXT: source: .debug_line_str[0x[[FILE1SRC:[0-9a-f]+]]] = "void foo() {}" # CHECK-NEXT: source: .debug_line_str[0x[[FILE1SRC:[0-9a-f]+]]] = "void foo() {}"
# CHECK: file_names[ 2]: # CHECK: file_names[ 1]:
# CHECK-NEXT: name: .debug_line_str[0x[[FILE2:[0-9a-f]+]]] = "bar" # CHECK-NEXT: name: .debug_line_str[0x[[FILE2:[0-9a-f]+]]] = "bar"
# CHECK-NEXT: dir_index: 2 # CHECK-NEXT: dir_index: 2
# CHECK-NEXT: source: .debug_line_str[0x[[FILE2SRC:[0-9a-f]+]]] = "void bar()\n{\n}" # CHECK-NEXT: source: .debug_line_str[0x[[FILE2SRC:[0-9a-f]+]]] = "void bar()\n{\n}"
# CHECK: .debug_line_str contents: # CHECK: .debug_line_str contents:
# CHECK-NEXT: 0x[[DIR0]]: "{{.+}}" # CHECK-NEXT: 0x[[DIR0]]: ""
# CHECK-NEXT: 0x[[DIR1]]: "dir1" # CHECK-NEXT: 0x[[DIR1]]: "dir1"
# CHECK-NEXT: 0x[[DIR2]]: "dir2" # CHECK-NEXT: 0x[[DIR2]]: "dir2"
# CHECK-NEXT: 0x[[FILE0]]: "{{.+}}"
# CHECK-NEXT: 0x[[FILE0SRC]]: ""
# CHECK-NEXT: 0x[[FILE1]]: "foo" # CHECK-NEXT: 0x[[FILE1]]: "foo"
# CHECK-NEXT: 0x[[FILE1SRC]]: "void foo() {}" # CHECK-NEXT: 0x[[FILE1SRC]]: "void foo() {}"
# CHECK-NEXT: 0x[[FILE2]]: "bar" # CHECK-NEXT: 0x[[FILE2]]: "bar"

View File

@ -1,19 +0,0 @@
# RUN: llvm-mc -dwarf-version 4 %s -filetype=obj -o - | llvm-dwarfdump -debug-line - | FileCheck %s --check-prefixes=CHECK,CHECK-4
# RUN: llvm-mc -dwarf-version 5 %s -filetype=obj -o - | llvm-dwarfdump -debug-line - | FileCheck %s --check-prefixes=CHECK,CHECK-5
# Darwin is stuck on DWARF v2.
# XFAIL: darwin
.file 0 "root.cpp"
.file 1 "header.h"
.file 2 "root.cpp"
# CHECK-5: include_directories[ 0] = ""
# CHECK-4-NOT: include_directories
# CHECK-4-NOT: file_names[ 0]
# CHECK-5: file_names[ 0]:
# CHECK-5-NEXT: name: "root.cpp"
# CHECK-5-NEXT: dir_index: 0
# CHECK: file_names[ 1]:
# CHECK-NEXT: name: "header.h"
# CHECK-NEXT: dir_index: 0
# CHECK: file_names[ 2]:
# CHECK-NEXT: name: "root.cpp"
# CHECK-NEXT: dir_index: 0

View File

@ -390,18 +390,6 @@ int main(int argc, char **argv) {
} }
if (!MainFileName.empty()) if (!MainFileName.empty())
Ctx.setMainFileName(MainFileName); Ctx.setMainFileName(MainFileName);
if (DwarfVersion >= 5) {
// DWARF v5 needs the root file as well as the compilation directory.
// If we find a '.file 0' directive that will supersede these values.
MD5 Hash;
MD5::MD5Result *Cksum =
(MD5::MD5Result *)Ctx.allocate(sizeof(MD5::MD5Result), 1);
Hash.update(Buffer->getBuffer());
Hash.final(*Cksum);
Ctx.setMCLineTableRootFile(
/*CUID=*/0, Ctx.getCompilationDir(),
!MainFileName.empty() ? MainFileName : InputFilename, Cksum, None);
}
// Package up features to be passed to target/subtarget // Package up features to be passed to target/subtarget
std::string FeaturesStr; std::string FeaturesStr;