Skip to content

Commit 204bfb6

Browse files
committed
Support 128-bit enum variant in debuginfo codegen
1 parent 397641f commit 204bfb6

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

Diff for: compiler/rustc_codegen_gcc/src/common.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
108108
self.const_uint(self.type_u64(), i)
109109
}
110110

111+
fn const_u128(&self, i: u128) -> RValue<'gcc> {
112+
self.const_uint_big(self.type_u128(), i)
113+
}
114+
111115
fn const_usize(&self, i: u64) -> RValue<'gcc> {
112116
let bit_size = self.data_layout().pointer_size.bits();
113117
if bit_size < 64 {
@@ -254,7 +258,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
254258
// SIMD builtins require a constant value.
255259
self.bitcast_if_needed(value, typ)
256260
}
257-
261+
258262
fn const_ptr_byte_offset(&self, base_addr: Self::Value, offset: abi::Size) -> Self::Value {
259263
self.context.new_array_access(None, base_addr, self.const_usize(offset.bytes())).get_address(None)
260264
}

Diff for: compiler/rustc_codegen_llvm/src/common.rs

+4
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
168168
self.const_uint(self.type_i64(), i)
169169
}
170170

171+
fn const_u128(&self, i: u128) -> &'ll Value {
172+
self.const_uint_big(self.type_i128(), i)
173+
}
174+
171175
fn const_usize(&self, i: u64) -> &'ll Value {
172176
let bit_size = self.data_layout().pointer_size.bits();
173177
if bit_size < 64 {

Diff for: compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ pub fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll D
429429
return existing_di_node;
430430
}
431431

432-
debug!("type_di_node: {:?}", t);
432+
debug!("type_di_node: {:?} kind: {:?}", t, t.kind());
433433

434434
let DINodeCreationResult { di_node, already_stored_in_typemap } = match *t.kind() {
435435
ty::Never | ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) => {

Diff for: compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,7 @@ fn build_enum_variant_member_di_node<'ll, 'tcx>(
412412
enum_type_and_layout.size.bits(),
413413
enum_type_and_layout.align.abi.bits() as u32,
414414
Size::ZERO.bits(),
415-
discr_value.opt_single_val().map(|value| {
416-
// NOTE(eddyb) do *NOT* remove this assert, until
417-
// we pass the full 128-bit value to LLVM, otherwise
418-
// truncation will be silent and remain undetected.
419-
assert_eq!(value as u64 as u128, value);
420-
cx.const_u64(value as u64)
421-
}),
415+
discr_value.opt_single_val().map(|value| cx.const_u128(value)),
422416
DIFlags::FlagZero,
423417
variant_member_info.variant_struct_type_di_node,
424418
)

Diff for: compiler/rustc_codegen_ssa/src/traits/consts.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub trait ConstMethods<'tcx>: BackendTypes {
1515
fn const_i32(&self, i: i32) -> Self::Value;
1616
fn const_u32(&self, i: u32) -> Self::Value;
1717
fn const_u64(&self, i: u64) -> Self::Value;
18+
fn const_u128(&self, i: u128) -> Self::Value;
1819
fn const_usize(&self, i: u64) -> Self::Value;
1920
fn const_u8(&self, i: u8) -> Self::Value;
2021
fn const_real(&self, t: Self::Type, val: f64) -> Self::Value;

0 commit comments

Comments
 (0)