[llvm] r270806 - PR11740: Disable assembly debug info when assembly already contains line directives
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Wed May 25 17:22:27 PDT 2016
Author: dblaikie
Date: Wed May 25 19:22:26 2016
New Revision: 270806
URL: http://llvm.org/viewvc/llvm-project?rev=270806&view=rev
Log:
PR11740: Disable assembly debug info when assembly already contains line directives
If there is already debug info in the assembly file, and user hope to
use -g option for compiling, we think we should not directly report an
error.
According to what GNU assembler did, it just reused the debug info in
the assembly file, and turned off the DEBUG_TYPE option so that there
will be no new debug info emitted by assembler. This fix is just as what
GNU assembler did.
The concern is the situation that there are two .text sections in the
assembly file, one with debug info and the other one without. Currently
with this fix, the assembler will no longer generate any debug info for
the second .text section. And this is what GNU assembler exactly did for
this situation. So I think this still make some sense.
Patch by Zhizhou Yang!
Differential Revision: http://reviews.llvm.org/D20002
Added:
llvm/trunk/test/MC/AsmParser/directive_file-2.s
Removed:
llvm/trunk/test/MC/AsmParser/directive_file-errors.s
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=270806&r1=270805&r2=270806&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Wed May 25 19:22:26 2016
@@ -3001,12 +3001,11 @@ bool AsmParser::parseDirectiveFile(SMLoc
if (FileNumber == -1)
getStreamer().EmitFileDirective(Filename);
else {
+ // If there is -g option as well as debug info from directive file,
+ // we turn off -g option, directly use the existing debug info instead.
if (getContext().getGenDwarfForAssembly())
- Error(DirectiveLoc,
- "input can't have .file dwarf directives when -g is "
- "used to generate dwarf debug info for assembly code");
-
- if (getStreamer().EmitDwarfFileDirective(FileNumber, Directory, Filename) ==
+ getContext().setGenDwarfForAssembly(false);
+ else if (getStreamer().EmitDwarfFileDirective(FileNumber, Directory, Filename) ==
0)
Error(FileNumberLoc, "file number already allocated");
}
Added: llvm/trunk/test/MC/AsmParser/directive_file-2.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_file-2.s?rev=270806&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_file-2.s (added)
+++ llvm/trunk/test/MC/AsmParser/directive_file-2.s Wed May 25 19:22:26 2016
@@ -0,0 +1,11 @@
+// RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
+// Test for Bug 11740
+// This testcase has two directive files,
+// when compiled with -g, this testcase will not report error,
+// but keep the debug info existing in the assembly file.
+
+ .file "hello"
+ .file 1 "world"
+
+// CHECK: .file "hello"
+// CHECK: .file 1 "world"
Removed: llvm/trunk/test/MC/AsmParser/directive_file-errors.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_file-errors.s?rev=270805&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_file-errors.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_file-errors.s (removed)
@@ -1,9 +0,0 @@
-// RUN: not llvm-mc -g -triple i386-unknown-unknown %s 2> %t.err | FileCheck %s
-// RUN: FileCheck --check-prefix=CHECK-ERRORS %s < %t.err
-// Test for Bug 11740
-
- .file "hello"
- .file 1 "world"
-
-// CHECK: .file "hello"
-// CHECK-ERRORS:6:9: error: input can't have .file dwarf directives when -g is used to generate dwarf debug info for assembly code
More information about the llvm-commits
mailing list