llvm-project/llvm/lib/MC/MCParser
Fangrui Song 3e8ab54ba0 [MC] Upgrade DWARF version to 5 upon .file 0
Without `-dwarf-version`, llvm-mc uses the default `MCContext::DwarfVersion` 4.

Without `-gdwarf-N`, Clang cc1as uses `clang::driver::ToolChain::GetDefaultDwarfVersion`
which is 4 on many toolchains. Note: `clang -c` can synthesize .debug_info without -g.

There is currently a MCParser warning upon `.file 0` and MCParser errors upon
`.loc 0` if the DWARF version is less than 5. This causes friction to the
following usage:

```
clang -S -g -gdwarf-5 a.c

// MC warning due to .file 0, MC error due to .loc 0
clang -c a.s
llvm-mc -filetype=obj a.s
```

My idea is that we can just upgrade `MCContext::DwarfVersion` to 5 upon
`.file 0` to make the above commands work.

The downside is that for an explicit version `clang -c -gdwarf-4 a.s`, it can be
argued that the new behavior drops the probably intended diagnostic. I think the
downside is small because in most cases DWARF version for an assembly action
should either match the original compile action or be omitted.

Ongoing discussion taking a similar action for GNU as: https://sourceware.org/pipermail/binutils/2021-January/114980.html

Differential Revision: https://reviews.llvm.org/D94882
2021-02-02 09:41:05 -08:00
..
AsmLexer.cpp [MC] Fix ICE with non-newline terminated input 2020-12-09 23:39:32 +00:00
AsmParser.cpp [MC] Upgrade DWARF version to 5 upon .file 0 2021-02-02 09:41:05 -08:00
CMakeLists.txt llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
COFFAsmParser.cpp [MC] Delete unused declarations 2020-12-06 15:36:39 -08:00
COFFMasmParser.cpp [llvm] Don't include StringSwitch.h where unnecessary (NFC) 2021-01-21 19:59:48 -08:00
DarwinAsmParser.cpp [MachO] Add skeletal support for DriverKit platform 2020-08-14 12:36:43 -07:00
ELFAsmParser.cpp [MC] Support SHF_GNU_RETAIN as section flag 'R' 2021-02-02 09:34:09 -08:00
MCAsmLexer.cpp
MCAsmParser.cpp [ms] [llvm-ml] Add a draft MASM parser 2020-02-16 12:30:46 -05:00
MCAsmParserExtension.cpp [COFF] Add cg_profile directive and .llvm.call-graph-profile section 2020-07-10 17:07:30 -07:00
MCTargetAsmParser.cpp
MasmParser.cpp [llvm] Use llvm::append_range (NFC) 2021-01-06 18:27:33 -08:00
WasmAsmParser.cpp [WebAssembly] Support COMDAT sections in assembly syntax 2020-12-10 16:43:59 -08:00