llvm-project
9f32dc30 - [Reland][DwarfDebug] Add applyDwarfVersion() so the targets like NVPTX can recompute the version-derived state (#243256)

Commit
1 day ago
[Reland][DwarfDebug] Add applyDwarfVersion() so the targets like NVPTX can recompute the version-derived state (#243256) `DwarfDebug` derives several settings such as DWARF64, accelerator table kind, GNU TLS opcode, DWARF2 bitfields, segmented string offsets, .debug_macro, MinimizeAddr, and the MCContext version and format from the DWARF version in its constructor. A target that overrides the version after construction could change only the MCContext value, leaving the rest derived from a different version. This change refactors this version-derived state into DwarfDebug::applyDwarfVersion(unsigned), which the constructor calls and a target subclass can call again. The version-independent part of the constructor is unchanged. `NVPTXDwarfDebug`, which always emits DWARF `v2`, calls this function to set version 2. This fixes a module with no "Dwarf Version" flag getting a v2 header with v4 encodings (`DW_AT_data_bit_offset` instead of `DW_AT_bit_offset`). Behavior for other targets is unchanged. Assisted by AI.
Author
Parents
Loading