rust/tests/codegen/enum
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
..
enum-bounds-check-derived-idx.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
enum-bounds-check-issue-13926.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
enum-bounds-check-issue-82871.rs [AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives 2024-02-22 16:04:04 +00:00
enum-bounds-check.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
enum-debug-clike.rs Run rustfmt on `tests/codegen/`. 2024-05-31 15:56:43 +10:00
enum-debug-niche-2.rs debuginfo: Set bitwidth appropriately in enum variant tags 2025-02-12 18:01:42 +00:00
enum-debug-niche.rs Run rustfmt on `tests/codegen/`. 2024-05-31 15:56:43 +10:00
enum-debug-tagged.rs Run rustfmt on `tests/codegen/`. 2024-05-31 15:56:43 +10:00
enum-discriminant-value.rs [AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives 2024-02-22 16:04:04 +00:00
enum-early-otherwise-branch.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
enum-match.rs Add range attribute to scalar function results and arguments 2024-08-11 19:40:44 +02:00
enum-u128.rs Update test directives for `wasm32-wasip1` 2024-03-11 09:36:35 -07:00
unreachable_enum_default_branch.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00