Skip to content

Commit 6269bc7

Browse files
committed
Support 128-bit discriminants in debuginfo
1 parent c28084a commit 6269bc7

File tree

5 files changed

+68
-12
lines changed

5 files changed

+68
-12
lines changed

src/librustc_codegen_llvm/debuginfo/metadata.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ struct MemberDescription<'ll> {
10191019
size: Size,
10201020
align: Align,
10211021
flags: DIFlags,
1022-
discriminant: Option<u64>,
1022+
discriminant: Option<u128>,
10231023
}
10241024

10251025
impl<'ll> MemberDescription<'ll> {
@@ -1039,7 +1039,7 @@ impl<'ll> MemberDescription<'ll> {
10391039
self.offset.bits(),
10401040
match self.discriminant {
10411041
None => None,
1042-
Some(value) => Some(cx.const_u64(value)),
1042+
Some(value) => Some(cx.const_uint_big(cx.type_i128(), value)),
10431043
},
10441044
self.flags,
10451045
self.type_metadata)
@@ -1418,7 +1418,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
14181418
align: self.layout.align.abi,
14191419
flags: DIFlags::FlagZero,
14201420
discriminant: Some(
1421-
self.layout.ty.discriminant_for_variant(cx.tcx, i).unwrap().val as u64
1421+
self.layout.ty.discriminant_for_variant(cx.tcx, i).unwrap().val
14221422
),
14231423
}
14241424
}).collect()
@@ -1521,12 +1521,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
15211521
let value = (i.as_u32() as u128)
15221522
.wrapping_sub(niche_variants.start().as_u32() as u128)
15231523
.wrapping_add(niche_start);
1524-
let value = truncate(value, discr.value.size(cx));
1525-
// NOTE(eddyb) do *NOT* remove this assert, until
1526-
// we pass the full 128-bit value to LLVM, otherwise
1527-
// truncation will be silent and remain undetected.
1528-
assert_eq!(value as u64 as u128, value);
1529-
Some(value as u64)
1524+
Some(truncate(value, discr.value.size(cx)))
15301525
};
15311526

15321527
MemberDescription {

src/test/codegen/enum-debug-niche-2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// compile-flags: -g -C no-prepopulate-passes
1010

1111
// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}}
12-
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i64 4294967295{{[,)].*}}
13-
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i64 0{{[,)].*}}
12+
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i128 4294967295{{[,)].*}}
13+
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i128 0{{[,)].*}}
1414

1515
#![feature(never_type)]
1616

src/test/codegen/repr-u128.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// ignore-tidy-linelength
2+
// ignore-windows
3+
// min-system-llvm-version 8.0
4+
5+
// compile-flags: -g -C no-prepopulate-passes
6+
7+
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "None",{{.*}}extraData: i128 18446745000000000124{{[,)].*}}
8+
9+
#![feature(repr128)]
10+
11+
#[repr(u128)]
12+
pub enum Foo {
13+
Lo,
14+
Hi = 1 << 64,
15+
Bar = 18_446_745_000_000_000_123,
16+
}
17+
18+
pub fn foo() -> Option<Foo> {
19+
None
20+
}
21+
22+
fn main() {
23+
let roa = foo();
24+
}

src/test/debuginfo/issue-22656.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// lldbg-check:[...]$0 = vec![1, 2, 3]
1616
// lldbr-check:(alloc::vec::Vec<i32>) v = vec![1, 2, 3]
1717
// lldb-command:print zs
18-
// lldbg-check:[...]$1 = StructWithZeroSizedField { x: ZeroSizedStruct, y: 123, z: ZeroSizedStruct, w: 456 }
18+
// lldbg-check:[...]$1 = StructWithZeroSizedField { x: ZeroSizedStruct { }, y: 123, z: ZeroSizedStruct { }, w: 456 }
1919
// lldbr-check:(issue_22656::StructWithZeroSizedField) zs = StructWithZeroSizedField { x: ZeroSizedStruct { }, y: 123, z: ZeroSizedStruct { }, w: 456 }
2020
// lldbr-command:continue
2121

src/test/debuginfo/repr-u128.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// ignore-windows
2+
// ignore-tidy-linelength
3+
// min-system-llvm-version 8.0
4+
5+
// compile-flags: -g -C no-prepopulate-passes
6+
7+
// === GDB TESTS ===================================================================================
8+
9+
// gdb-command: run
10+
11+
// gdb-command:print vals
12+
// gdb-check:$1 = (core::option::Option<repr_u128::Foo>, core::option::Option<repr_u128::Foo>)
13+
14+
// === LLDB TESTS ==================================================================================
15+
16+
// lldb-command:run
17+
18+
// lldb-command:print vals
19+
// lldbg-check:[...]$0 = (Option<repr_u128::Foo> { }, Option<repr_u128::Foo> { })
20+
// lldbr-check:((core::option::Option<repr_u128::Foo>, core::option::Option<repr_u128::Foo>)) $0 = (Option<repr_u128::Foo> { }, Option<repr_u128::Foo> { })
21+
22+
#![feature(repr128)]
23+
24+
#[repr(u128)]
25+
pub enum Foo {
26+
Lo,
27+
Hi = 1 << 64,
28+
Bar = 18_446_745_000_000_000_123,
29+
}
30+
31+
fn main() {
32+
let vals = (Some(Foo::Lo), None::<Foo>);
33+
34+
zzz(); // #break
35+
}
36+
37+
fn zzz() {()}

0 commit comments

Comments
 (0)