diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -65,7 +65,6 @@ StringRef Filename, Optional Checksum, Optional Source, - bool UseDwarfDirectory, raw_svector_ostream &OS) const; void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override; void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override; @@ -1450,13 +1449,16 @@ EmitEOL(); } -void MCAsmStreamer::printDwarfFileDirective( - unsigned FileNo, StringRef Directory, StringRef Filename, - Optional Checksum, Optional Source, - bool UseDwarfDirectory, raw_svector_ostream &OS) const { +void MCAsmStreamer::printDwarfFileDirective(unsigned FileNo, + StringRef Directory, + StringRef Filename, + Optional Checksum, + Optional Source, + raw_svector_ostream &OS) const { SmallString<128> FullPathName; - if (!UseDwarfDirectory && !Directory.empty()) { + if (getContext().getDwarfVersion() < 5 && !UseDwarfDirectory && + !Directory.empty()) { if (sys::path::is_absolute(Filename)) Directory = ""; else { @@ -1503,8 +1505,7 @@ SmallString<128> Str; raw_svector_ostream OS1(Str); - printDwarfFileDirective(FileNo, Directory, Filename, Checksum, Source, - UseDwarfDirectory, OS1); + printDwarfFileDirective(FileNo, Directory, Filename, Checksum, Source, OS1); if (MCTargetStreamer *TS = getTargetStreamer()) TS->emitDwarfFileDirective(OS1.str()); @@ -1533,8 +1534,7 @@ SmallString<128> Str; raw_svector_ostream OS1(Str); - printDwarfFileDirective(0, Directory, Filename, Checksum, Source, - UseDwarfDirectory, OS1); + printDwarfFileDirective(0, Directory, Filename, Checksum, Source, OS1); if (MCTargetStreamer *TS = getTargetStreamer()) TS->emitDwarfFileDirective(OS1.str()); diff --git a/llvm/test/CodeGen/Generic/dwarf-md5.ll b/llvm/test/CodeGen/Generic/dwarf-md5.ll --- a/llvm/test/CodeGen/Generic/dwarf-md5.ll +++ b/llvm/test/CodeGen/Generic/dwarf-md5.ll @@ -14,7 +14,7 @@ ; ASM-4-NOT: md5 ; ASM-4: .file 2 "/scratch{{.*[/\\]}}t2.h" ; ASM-4-NOT: md5 -; ASM-5: .file 0 "/scratch{{.*[/\\]}}t.c" md5 0x00000000000000000000000000000000 +; ASM-5: .file 0 "/scratch" "t.c" md5 0x00000000000000000000000000000000 ; ASM-5: .file 1 "t1.h" md5 0x11111111111111111111111111111111 ; ASM-5: .file 2 "t2.h" md5 0x22222222222222222222222222222222 diff --git a/llvm/test/CodeGen/Generic/dwarf-source.ll b/llvm/test/CodeGen/Generic/dwarf-source.ll --- a/llvm/test/CodeGen/Generic/dwarf-source.ll +++ b/llvm/test/CodeGen/Generic/dwarf-source.ll @@ -11,7 +11,7 @@ ; ASM-4: .file 1 "/test{{.*[/\\]}}t1.h" source "11111111111111111111111111111111" ; ASM-4: .file 2 "/test{{.*[/\\]}}t2.h" source "22222222222222222222222222222222" -; ASM-5: .file 0 "/test{{.*[/\\]}}t.c" source "00000000000000000000000000000000" +; ASM-5: .file 0 "/test" "t.c" source "00000000000000000000000000000000" ; ASM-5: .file 1 "t1.h" source "11111111111111111111111111111111" ; ASM-5: .file 2 "t2.h" source "22222222222222222222222222222222"