[DWARFv5] llvm-mc -dwarf-version does not imply -g.
Don't provide the assembler source as the "root file" unless the user
asked to have debug info for the assembler source (with -g).
If the source doesn't provide an explicit ".file 0" then (a) use the
compilation directory as directory #0, and (b) use the file #1 info
for file #0 also.
Differential Revision: https://reviews.llvm.org/D48055
llvm-svn: 334512
diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp
index 7b83c5e..9e69eee 100644
--- a/llvm/tools/llvm-mc/llvm-mc.cpp
+++ b/llvm/tools/llvm-mc/llvm-mc.cpp
@@ -389,7 +389,7 @@
}
if (!MainFileName.empty())
Ctx.setMainFileName(MainFileName);
- if (DwarfVersion >= 5) {
+ if (GenDwarfForAssembly && DwarfVersion >= 5) {
// DWARF v5 needs the root file as well as the compilation directory.
// If we find a '.file 0' directive that will supersede these values.
MD5 Hash;