From 4ca29477d9d6f219a92ba499f380fb57ffe00e8b Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Tue, 29 Jan 2019 20:53:51 +0000 Subject: [PATCH] [DWARF] Emit reasonable debug info for empty .s files. llvm-svn: 352541 --- llvm/lib/MC/MCParser/AsmParser.cpp | 3 +++ llvm/test/MC/AsmParser/debug-only-comments.s | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 llvm/test/MC/AsmParser/debug-only-comments.s diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index ee9ed0d..b2ff1e1 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -900,6 +900,9 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) { eatToEndOfStatement(); } + // Make sure we get proper DWARF even for empty files. + (void)enabledGenDwarfForAssembly(); + getTargetParser().onEndOfFile(); printPendingErrors(); diff --git a/llvm/test/MC/AsmParser/debug-only-comments.s b/llvm/test/MC/AsmParser/debug-only-comments.s new file mode 100644 index 0000000..0330653 --- /dev/null +++ b/llvm/test/MC/AsmParser/debug-only-comments.s @@ -0,0 +1,6 @@ + # RUN: llvm-mc -triple i386-linux-gnu -g -dwarf-version 4 < %s | FileCheck %s + # RUN: llvm-mc -triple i386-linux-gnu -g -dwarf-version 5 < %s | FileCheck %s + # CHECK: .section .debug_info + # CHECK: .section .debug_info + # CHECK-NOT: .section + # CHECK: .ascii "" -- 2.7.4