[PATCH] D57772: [MC] Don't error on numberless .file directives on MachO
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 5 11:24:46 PST 2019
rnk created this revision.
rnk added a reviewer: mstorsjo.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
Before r349976, MC ignored such directives when producing an object file
and asserted when re-producing textual assembly output. I turned this
assertion into a hard error in both cases in r349976, but this makes it
unnecessarily difficult to write a single assembly file that supports
both MachO and other object formats that support .file. A user reported
this as PR40578, and we decided to go back to ignoring the directive.
Fixes PR40578
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D57772
Files:
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/test/MC/MachO/file-single.s
llvm/test/MC/MachO/file.s
Index: llvm/test/MC/MachO/file.s
===================================================================
--- llvm/test/MC/MachO/file.s
+++ llvm/test/MC/MachO/file.s
@@ -1,5 +1,8 @@
// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | llvm-readobj -s -section-data | FileCheck %s
+// This number-less file directive is ignored on MachO.
+ .file "bar/baz.s"
+
.file 1 "dir/foo"
nop
Index: llvm/test/MC/MachO/file-single.s
===================================================================
--- llvm/test/MC/MachO/file-single.s
+++ /dev/null
@@ -1,8 +0,0 @@
-// 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/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -3370,10 +3370,11 @@
}
if (FileNumber == -1) {
- if (!getContext().getAsmInfo()->hasSingleParameterDotFile())
- return Error(DirectiveLoc,
- "target does not support '.file' without a number");
- getStreamer().EmitFileDirective(Filename);
+ // Ignore the directive if there is no number and the target doesn't support
+ // numberless .file directives. This allows some portability of assembler
+ // between different object file formats.
+ if (getContext().getAsmInfo()->hasSingleParameterDotFile())
+ getStreamer().EmitFileDirective(Filename);
} 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57772.185358.patch
Type: text/x-patch
Size: 1786 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190205/069cc9a2/attachment.bin>
More information about the llvm-commits
mailing list