[PATCH] D55900: [MC] Enable .file support on COFF and diagnose it on unsupported targets

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 21 15:39:18 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL349976: [MC] Enable .file support on COFF and diagnose it on unsupported targets (authored by rnk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55900?vs=178950&id=179373#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55900

Files:
  llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp
  llvm/trunk/lib/MC/MCParser/AsmParser.cpp
  llvm/trunk/test/MC/COFF/file.s
  llvm/trunk/test/MC/MachO/file-single.s


Index: llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp
===================================================================
--- llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp
+++ llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp
@@ -25,7 +25,7 @@
   COMMDirectiveAlignmentIsInBytes = false;
   LCOMMDirectiveAlignmentType = LCOMM::ByteAlignment;
   HasDotTypeDotSizeDirective = false;
-  HasSingleParameterDotFile = false;
+  HasSingleParameterDotFile = true;
   WeakRefDirective = "\t.weak\t";
   HasLinkOnceDirective = true;
 
Index: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp
@@ -3360,9 +3360,12 @@
     }
   }
 
-  if (FileNumber == -1)
+  if (FileNumber == -1) {
+    if (!getContext().getAsmInfo()->hasSingleParameterDotFile())
+      return Error(DirectiveLoc,
+                   "target does not support '.file' without a number");
     getStreamer().EmitFileDirective(Filename);
-  else {
+  } else {
     // In case there is a -g option as well as debug info from directive .file,
     // we turn off the -g option, directly use the existing debug info instead.
     // Also reset any implicit ".file 0" for the assembler source.
Index: llvm/trunk/test/MC/MachO/file-single.s
===================================================================
--- llvm/trunk/test/MC/MachO/file-single.s
+++ llvm/trunk/test/MC/MachO/file-single.s
@@ -0,0 +1,8 @@
+// RUN: not llvm-mc -triple i386-apple-darwin9 %s -o /dev/null 2>&1 | FileCheck %s
+
+// Previously this crashed MC.
+
+// CHECK: error: target does not support '.file' without a number
+
+        .file "dir/foo"
+        nop
Index: llvm/trunk/test/MC/COFF/file.s
===================================================================
--- llvm/trunk/test/MC/COFF/file.s
+++ llvm/trunk/test/MC/COFF/file.s
@@ -1,6 +1,11 @@
 // RUN: llvm-mc -triple i686-windows -filetype obj %s -o - | llvm-objdump -t - \
 // RUN:   | FileCheck %s
 
+// Round trip through .s output to exercise MCAsmStreamer.
+// RUN: llvm-mc -triple i686-windows %s -o - \
+// RUN:   | llvm-mc -triple i686-windows - -filetype=obj -o - | llvm-objdump -t - \
+// RUN:   | FileCheck %s
+
 // RUN: llvm-mc -triple i686-windows -filetype obj %s -o - \
 // RUN:	  | llvm-readobj -symbols | FileCheck %s -check-prefix CHECK-SCN
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55900.179373.patch
Type: text/x-patch
Size: 2364 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181221/19792f20/attachment.bin>


More information about the llvm-commits mailing list