[PATCH] D20002: Fix Bug 11740: Turn off -g when there are directive file debug info

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed May 25 17:28:47 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL270806: PR11740: Disable assembly debug info when assembly already contains lineā€¦ (authored by dblaikie).

Changed prior to commit:
  http://reviews.llvm.org/D20002?vs=57978&id=58547#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20002

Files:
  llvm/trunk/lib/MC/MCParser/AsmParser.cpp
  llvm/trunk/test/MC/AsmParser/directive_file-2.s
  llvm/trunk/test/MC/AsmParser/directive_file-errors.s

Index: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp
@@ -3001,12 +3001,11 @@
   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");
   }
Index: llvm/trunk/test/MC/AsmParser/directive_file-2.s
===================================================================
--- llvm/trunk/test/MC/AsmParser/directive_file-2.s
+++ llvm/trunk/test/MC/AsmParser/directive_file-2.s
@@ -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"
Index: llvm/trunk/test/MC/AsmParser/directive_file-errors.s
===================================================================
--- llvm/trunk/test/MC/AsmParser/directive_file-errors.s
+++ llvm/trunk/test/MC/AsmParser/directive_file-errors.s
@@ -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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20002.58547.patch
Type: text/x-patch
Size: 2206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160526/f675089b/attachment.bin>


More information about the llvm-commits mailing list