rust/compiler/rustc_codegen_llvm/src/debuginfo
Jubilee 864eba9fb1
Rollup merge of #136895 - maurer:fix-enum-discr, r=nikic
debuginfo: Set bitwidth appropriately in enum variant tags

Previously, we unconditionally set the bitwidth to 128-bits, the largest an enum would possibly be. Then, LLVM would cut down the constant by chopping off leading zeroes before emitting the DWARF. LLVM only supported 64-bit enumerators, so this would also have occasionally resulted in truncated data.

LLVM added support for 128-bit enumerators in llvm/llvm-project#125578

That patchset trusts the constant to describe how wide the variant tag is, so the high 64-bits of zeros are considered potentially load-bearing.

As a result, we went from emitting tags that looked like:
DW_AT_discr_value     (0xfe)

(because `dwarf::BestForm` selected `data1`)

to emitting tags that looked like:
DW_AT_discr_value	(<0x10> fe ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 )

This makes the `DW_AT_discr_value` encode at the bitwidth of the tag, which:
1. Is probably closer to our intentions in terms of describing the data.
2. Doesn't invoke the 128-bit support which may not be supported by all debuggers / downstream tools.
3. Will result in smaller debug information.
2025-02-13 17:46:08 -08:00
..
metadata debuginfo: Set bitwidth appropriately in enum variant tags 2025-02-12 18:01:42 +00:00
create_scope_map.rs Use LLVMDIBuilderCreateLexicalBlock 2025-02-01 14:14:40 +11:00
doc.md fix most compiler/ doctests 2022-05-02 17:40:30 -07:00
dwarf_const.rs Use constants for DWARF opcodes, instead of FFI calls 2025-01-05 22:16:25 +11:00
gdb.rs Document some safety constraints and use more safe wrappers 2025-02-11 09:47:13 +00:00
metadata.rs Debuginfo for function ZSTs should have alignment of 8 bits, not 1 bit 2025-02-06 23:01:29 +11:00
mod.rs Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrum 2025-02-09 15:44:16 +00:00
namespace.rs Use LLVMDIBuilderCreateNameSpace 2025-02-01 14:14:39 +11:00
utils.rs Introduce DIBuilderBox, an owning pointer to DIBuilder 2025-02-01 13:34:14 +11:00