[PATCH] D105662: Fix incorrect DWARF 5 file name 0 when using -no-integrated-as

Omar Sandoval via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 8 16:47:54 PDT 2021


osandov updated this revision to Diff 357387.
osandov edited the summary of this revision.
osandov added a comment.
Herald added a subscriber: ormris.

The existing CodeGen tests already cover this, so I updated them.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105662/new/

https://reviews.llvm.org/D105662

Files:
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/test/CodeGen/Generic/dwarf-md5.ll
  llvm/test/CodeGen/Generic/dwarf-source.ll


Index: llvm/test/CodeGen/Generic/dwarf-source.ll
===================================================================
--- llvm/test/CodeGen/Generic/dwarf-source.ll
+++ 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"
 
Index: llvm/test/CodeGen/Generic/dwarf-md5.ll
===================================================================
--- llvm/test/CodeGen/Generic/dwarf-md5.ll
+++ 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
 
Index: llvm/lib/MC/MCAsmStreamer.cpp
===================================================================
--- llvm/lib/MC/MCAsmStreamer.cpp
+++ llvm/lib/MC/MCAsmStreamer.cpp
@@ -65,7 +65,6 @@
                                StringRef Filename,
                                Optional<MD5::MD5Result> Checksum,
                                Optional<StringRef> 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<MD5::MD5Result> Checksum, Optional<StringRef> Source,
-    bool UseDwarfDirectory, raw_svector_ostream &OS) const {
+void MCAsmStreamer::printDwarfFileDirective(unsigned FileNo,
+                                            StringRef Directory,
+                                            StringRef Filename,
+                                            Optional<MD5::MD5Result> Checksum,
+                                            Optional<StringRef> 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());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105662.357387.patch
Type: text/x-patch
Size: 3616 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210708/56fc8d94/attachment.bin>


More information about the llvm-commits mailing list