From 342309ebbbf8819d4eb03a8c10995d0dd2acb328 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Fri, 29 Mar 2019 16:36:14 +0900 Subject: [PATCH 01/17] Add assert --- src/librustc_codegen_llvm/debuginfo/metadata.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index e549b120da979..9381ed62a675c 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -1386,12 +1386,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { let value = (i.as_u32() as u128) .wrapping_sub(niche_variants.start().as_u32() as u128) .wrapping_add(niche_start); - let value = truncate(value, discr.value.size(cx)); - // NOTE(eddyb) do *NOT* remove this assert, until - // we pass the full 128-bit value to LLVM, otherwise - // truncation will be silent and remain undetected. - assert_eq!(value as u64 as u128, value); - Some(value as u64) + Some(truncate(value, niche.value.size(cx))) }; MemberDescription { From 70e726512ad227bfedce7b9ad8e115391bc034d1 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Fri, 29 Mar 2019 18:06:07 +0900 Subject: [PATCH 02/17] Expand uint --- src/librustc_codegen_llvm/debuginfo/metadata.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 9381ed62a675c..0b5ec3b41c65c 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -933,7 +933,7 @@ struct MemberDescription<'ll> { size: Size, align: Align, flags: DIFlags, - discriminant: Option, + discriminant: Option, } // A factory for MemberDescriptions. It produces a list of member descriptions @@ -1288,7 +1288,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { flags: DIFlags::FlagZero, discriminant: Some(self.layout.ty.ty_adt_def().unwrap() .discriminant_for_variant(cx.tcx, i) - .val as u64), + .val as u128), } }).collect() } @@ -1842,6 +1842,7 @@ fn set_members_of_composite_type(cx: &CodegenCx<'ll, 'tcx>, .into_iter() .map(|member_description| { let member_name = CString::new(member_description.name).unwrap(); + let align = member_description.align.bits() as u64; unsafe { Some(llvm::LLVMRustDIBuilderCreateVariantMemberType( DIB(cx), @@ -1854,7 +1855,8 @@ fn set_members_of_composite_type(cx: &CodegenCx<'ll, 'tcx>, member_description.offset.bits(), match member_description.discriminant { None => None, - Some(value) => Some(cx.const_u64(value)), + Some(value) => + Some(cx.const_uint_big(cx.type_ix(align), value)), }, member_description.flags, member_description.type_metadata)) From d7bb9de177cd65747d2c4c597dd6923a86ec28c7 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Sat, 30 Mar 2019 05:04:46 +0900 Subject: [PATCH 03/17] Clean up --- src/librustc_codegen_llvm/debuginfo/metadata.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 0b5ec3b41c65c..f6dcba2e3c6a5 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -1842,7 +1842,6 @@ fn set_members_of_composite_type(cx: &CodegenCx<'ll, 'tcx>, .into_iter() .map(|member_description| { let member_name = CString::new(member_description.name).unwrap(); - let align = member_description.align.bits() as u64; unsafe { Some(llvm::LLVMRustDIBuilderCreateVariantMemberType( DIB(cx), @@ -1856,7 +1855,7 @@ fn set_members_of_composite_type(cx: &CodegenCx<'ll, 'tcx>, match member_description.discriminant { None => None, Some(value) => - Some(cx.const_uint_big(cx.type_ix(align), value)), + Some(cx.const_uint_big(cx.type_i128(), value)), }, member_description.flags, member_description.type_metadata)) From 261c7c1503e3594e13fbcda07eda2c4fff59e767 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Sat, 30 Mar 2019 05:50:37 +0900 Subject: [PATCH 04/17] Remove unnecessary cast --- src/librustc_codegen_llvm/debuginfo/metadata.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index f6dcba2e3c6a5..cd231396e125c 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -1288,7 +1288,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { flags: DIFlags::FlagZero, discriminant: Some(self.layout.ty.ty_adt_def().unwrap() .discriminant_for_variant(cx.tcx, i) - .val as u128), + .val), } }).collect() } From bf3a744e0ddc90616e177027015bf02b931092af Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Sat, 30 Mar 2019 20:05:41 +0900 Subject: [PATCH 05/17] Add tests --- src/test/codegen/repr-u128.rs | 17 +++++++++++++++++ src/test/debuginfo/repr-u128.rs | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/test/codegen/repr-u128.rs create mode 100644 src/test/debuginfo/repr-u128.rs diff --git a/src/test/codegen/repr-u128.rs b/src/test/codegen/repr-u128.rs new file mode 100644 index 0000000000000..f41109e10f0e5 --- /dev/null +++ b/src/test/codegen/repr-u128.rs @@ -0,0 +1,17 @@ +// compile-flags: --emit=llvm-ir -C debuginfo=2 +#![feature(repr128)] + +#[repr(u128)] +pub enum Foo { + Lo, + Hi = 1 << 64, +} + +pub fn foo() -> Option { + None +} + +// CHECK: declare void @llvm.dbg.value +fn main() { + let vals = (Some(Foo::Lo), None::); +} diff --git a/src/test/debuginfo/repr-u128.rs b/src/test/debuginfo/repr-u128.rs new file mode 100644 index 0000000000000..f41109e10f0e5 --- /dev/null +++ b/src/test/debuginfo/repr-u128.rs @@ -0,0 +1,17 @@ +// compile-flags: --emit=llvm-ir -C debuginfo=2 +#![feature(repr128)] + +#[repr(u128)] +pub enum Foo { + Lo, + Hi = 1 << 64, +} + +pub fn foo() -> Option { + None +} + +// CHECK: declare void @llvm.dbg.value +fn main() { + let vals = (Some(Foo::Lo), None::); +} From cfe99bebfc70a8ede224de1b13f468ef4b5685b1 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Sun, 31 Mar 2019 02:12:21 +0900 Subject: [PATCH 06/17] Remove unnecessary variable --- src/test/codegen/repr-u128.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/test/codegen/repr-u128.rs b/src/test/codegen/repr-u128.rs index f41109e10f0e5..f277968c42ecb 100644 --- a/src/test/codegen/repr-u128.rs +++ b/src/test/codegen/repr-u128.rs @@ -12,6 +12,4 @@ pub fn foo() -> Option { } // CHECK: declare void @llvm.dbg.value -fn main() { - let vals = (Some(Foo::Lo), None::); -} +fn main() {} From 69dc278a0a95c665f7189db9778e3a92a0f1a3fc Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Sun, 31 Mar 2019 03:07:10 +0900 Subject: [PATCH 07/17] Add bar --- src/test/codegen/repr-u128.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/codegen/repr-u128.rs b/src/test/codegen/repr-u128.rs index f277968c42ecb..be41df97d9ee8 100644 --- a/src/test/codegen/repr-u128.rs +++ b/src/test/codegen/repr-u128.rs @@ -5,6 +5,7 @@ pub enum Foo { Lo, Hi = 1 << 64, + Bar = 18_446_745_000_000_000_123, } pub fn foo() -> Option { From 6fcd5bb15bdceb86d9ce1d6b63748803090deeae Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Sun, 31 Mar 2019 04:03:33 +0900 Subject: [PATCH 08/17] WIP: correct flags --- src/test/codegen/repr-u128.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/codegen/repr-u128.rs b/src/test/codegen/repr-u128.rs index be41df97d9ee8..c907c037546de 100644 --- a/src/test/codegen/repr-u128.rs +++ b/src/test/codegen/repr-u128.rs @@ -1,4 +1,7 @@ -// compile-flags: --emit=llvm-ir -C debuginfo=2 +// ignore-windows +//min-system-llvm-version 8.0 + +//compile-flags: -g -C no-prepopulate-passes #![feature(repr128)] #[repr(u128)] @@ -8,6 +11,7 @@ pub enum Foo { Bar = 18_446_745_000_000_000_123, } +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "None",{{.*}}extraData:{{.*}} pub fn foo() -> Option { None } From 1d12b064290e12d2a644117904dbf249af6ee0d0 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Tue, 2 Apr 2019 02:26:02 +0900 Subject: [PATCH 09/17] Fix variable name --- src/librustc_codegen_llvm/debuginfo/metadata.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index cd231396e125c..616f32af891ba 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -1386,7 +1386,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { let value = (i.as_u32() as u128) .wrapping_sub(niche_variants.start().as_u32() as u128) .wrapping_add(niche_start); - Some(truncate(value, niche.value.size(cx))) + Some(truncate(value, discr.value.size(cx))) }; MemberDescription { From 1aea502ae88f65b1719bf99100b88ad244445263 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Thu, 18 Apr 2019 02:22:03 +0900 Subject: [PATCH 10/17] Fix check --- src/test/codegen/repr-u128.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/codegen/repr-u128.rs b/src/test/codegen/repr-u128.rs index c907c037546de..34dd37017b910 100644 --- a/src/test/codegen/repr-u128.rs +++ b/src/test/codegen/repr-u128.rs @@ -11,10 +11,9 @@ pub enum Foo { Bar = 18_446_745_000_000_000_123, } -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "None",{{.*}}extraData:{{.*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "None",{{.*}}extraData:18446745000000000124 pub fn foo() -> Option { None } -// CHECK: declare void @llvm.dbg.value fn main() {} From 9b9a1f21077d573fa6bde78d06f442167c6216f5 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Thu, 18 Apr 2019 06:16:03 +0900 Subject: [PATCH 11/17] Separate comment --- src/test/codegen/repr-u128.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/codegen/repr-u128.rs b/src/test/codegen/repr-u128.rs index 34dd37017b910..8216ee4f3cabd 100644 --- a/src/test/codegen/repr-u128.rs +++ b/src/test/codegen/repr-u128.rs @@ -11,7 +11,8 @@ pub enum Foo { Bar = 18_446_745_000_000_000_123, } -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "None",{{.*}}extraData:18446745000000000124 +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}} +// name: "None",{{.*}}extraData:18446745000000000124 pub fn foo() -> Option { None } From d8454fc74de6341c9cc3755641ea58462533eba4 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Thu, 25 Apr 2019 05:48:17 +0900 Subject: [PATCH 12/17] Add flags --- src/test/debuginfo/repr-u128.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/debuginfo/repr-u128.rs b/src/test/debuginfo/repr-u128.rs index f41109e10f0e5..fed5651211d26 100644 --- a/src/test/debuginfo/repr-u128.rs +++ b/src/test/debuginfo/repr-u128.rs @@ -1,4 +1,7 @@ -// compile-flags: --emit=llvm-ir -C debuginfo=2 +// ignore-windows +//min-system-llvm-version 8.0 + +//compile-flags: -g -C no-prepopulate-passes #![feature(repr128)] #[repr(u128)] From dca8319c2c63f17fb31dd82554240acb529d2962 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Thu, 25 Apr 2019 05:53:08 +0900 Subject: [PATCH 13/17] Remove check flag --- src/test/debuginfo/repr-u128.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/test/debuginfo/repr-u128.rs b/src/test/debuginfo/repr-u128.rs index fed5651211d26..60d7eddbb430a 100644 --- a/src/test/debuginfo/repr-u128.rs +++ b/src/test/debuginfo/repr-u128.rs @@ -10,11 +10,6 @@ pub enum Foo { Hi = 1 << 64, } -pub fn foo() -> Option { - None -} - -// CHECK: declare void @llvm.dbg.value fn main() { let vals = (Some(Foo::Lo), None::); } From e21077c1512395cdaa98f2815abbd34aeb7ce524 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Thu, 25 Apr 2019 07:20:19 +0900 Subject: [PATCH 14/17] WIP: fix debuginfo test --- src/test/debuginfo/repr-u128.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/debuginfo/repr-u128.rs b/src/test/debuginfo/repr-u128.rs index 60d7eddbb430a..64157e532c753 100644 --- a/src/test/debuginfo/repr-u128.rs +++ b/src/test/debuginfo/repr-u128.rs @@ -2,12 +2,19 @@ //min-system-llvm-version 8.0 //compile-flags: -g -C no-prepopulate-passes + +// === GDB TESTS =================================================================================== + +// gdb-command: run + + #![feature(repr128)] #[repr(u128)] pub enum Foo { Lo, Hi = 1 << 64, + Bar = 18_446_745_000_000_000_123, } fn main() { From a197466f4dfc230cbb482971a592def00aeec4f2 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Wed, 1 May 2019 01:25:19 +0900 Subject: [PATCH 15/17] Ignore line length --- src/test/codegen/repr-u128.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/codegen/repr-u128.rs b/src/test/codegen/repr-u128.rs index 8216ee4f3cabd..be2960bed3a00 100644 --- a/src/test/codegen/repr-u128.rs +++ b/src/test/codegen/repr-u128.rs @@ -1,4 +1,5 @@ // ignore-windows +// ignore-tidy-linelength //min-system-llvm-version 8.0 //compile-flags: -g -C no-prepopulate-passes @@ -11,8 +12,7 @@ pub enum Foo { Bar = 18_446_745_000_000_000_123, } -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}} -// name: "None",{{.*}}extraData:18446745000000000124 +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "None",{{.*}}extraData:18446745000000000124 pub fn foo() -> Option { None } From 4315c78191eba9877eaa86c3ce9f42e661bcdd5e Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Wed, 1 May 2019 04:06:25 +0900 Subject: [PATCH 16/17] WIP: add some flags for debuginfo --- src/test/debuginfo/repr-u128.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/debuginfo/repr-u128.rs b/src/test/debuginfo/repr-u128.rs index 64157e532c753..5ab444b22fb55 100644 --- a/src/test/debuginfo/repr-u128.rs +++ b/src/test/debuginfo/repr-u128.rs @@ -7,6 +7,17 @@ // gdb-command: run +// gdb-command:print vals +// gdbg-check:$1 = (Some(Foo::Lo), None::) +// gdbr-check:$1 = repr_u128::Foo::(std::option::Option, std::option::Option) + +// === LLDB TESTS ================================================================================== + +// lldb-command:run + +// lldb-command:print vals +// lldbg-check:[...]$0 = (Some(Foo::Lo), None::) +// lldbr-check:(repr_u128::Foo) vals = repr_u128::Foo::(std::option::Option, std::option::Option) #![feature(repr128)] From 6ed4b52142a8167aadd1aa2188922487103dbb51 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Wed, 1 May 2019 04:29:49 +0900 Subject: [PATCH 17/17] Ignore line length --- src/test/debuginfo/repr-u128.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/debuginfo/repr-u128.rs b/src/test/debuginfo/repr-u128.rs index 5ab444b22fb55..da71ec6aadc13 100644 --- a/src/test/debuginfo/repr-u128.rs +++ b/src/test/debuginfo/repr-u128.rs @@ -1,4 +1,5 @@ // ignore-windows +// ignore-tidy-linelength //min-system-llvm-version 8.0 //compile-flags: -g -C no-prepopulate-passes