about summary refs log tree commit diff
path: root/tests/codegen/enum/enum-debug-niche-2.rs
diff options
context:
space:
mode:
authorMatthew Maurer <mmaurer@google.com>2025-02-12 00:37:33 +0000
committerMatthew Maurer <mmaurer@google.com>2025-02-12 18:01:42 +0000
commitd82219a4fa06bfa47fc5aac64844c461905ae77d (patch)
tree3284087de39b5f13c0f65e75dbfadc20268597b6 /tests/codegen/enum/enum-debug-niche-2.rs
parent8c61cd4df8434573190336b8f16169f3c2b22a7a (diff)
downloadrust-d82219a4fa06bfa47fc5aac64844c461905ae77d.tar.gz
rust-d82219a4fa06bfa47fc5aac64844c461905ae77d.zip
debuginfo: Set bitwidth appropriately in enum variant tags
Previously, we unconditionally set the bitwidth to 128-bits, the largest
an discrimnator would possibly be. Then, LLVM would cut down the constant by
chopping off leading zeroes before emitting the DWARF. LLVM only
supported 64-bit descriminators, so this would also have occasionally
resulted in truncated data (or an assert) if more than 64-bits were
used.

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

That patchset also trusts the constant to describe how wide the variant tag is.
As a result, we went from emitting tags that looked like:
DW_AT_discr_value     (0xfe)

(`form1`)

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.
Diffstat (limited to 'tests/codegen/enum/enum-debug-niche-2.rs')
-rw-r--r--tests/codegen/enum/enum-debug-niche-2.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/codegen/enum/enum-debug-niche-2.rs b/tests/codegen/enum/enum-debug-niche-2.rs
index 58f43fe3ec6..80a4081f15b 100644
--- a/tests/codegen/enum/enum-debug-niche-2.rs
+++ b/tests/codegen/enum/enum-debug-niche-2.rs
@@ -5,8 +5,8 @@
 //@ ignore-msvc
 //
 // CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}}
-// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i128 4294967295{{[,)].*}}
-// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i128 0{{[,)].*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i32 -1{{[,)].*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i32 0{{[,)].*}}
 #![feature(never_type)]
 
 #[derive(Copy, Clone)]