Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1f34b19

Browse files
committedMar 18, 2025
Avoid splitting up a layout
1 parent 018032c commit 1f34b19

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed
 

‎compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
245245
cx,
246246
owner,
247247
addr_field_name,
248-
(addr_field.size, addr_field.align.abi),
248+
addr_field,
249249
layout.fields.offset(WIDE_PTR_ADDR),
250250
DIFlags::FlagZero,
251251
data_ptr_type_di_node,
@@ -255,7 +255,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
255255
cx,
256256
owner,
257257
extra_field_name,
258-
(extra_field.size, extra_field.align.abi),
258+
extra_field,
259259
layout.fields.offset(WIDE_PTR_EXTRA),
260260
DIFlags::FlagZero,
261261
type_di_node(cx, extra_field.ty),
@@ -738,7 +738,7 @@ fn build_cpp_f16_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) -> DINodeCreation
738738
cx,
739739
float_di_node,
740740
"bits",
741-
cx.size_and_align_of(bits_ty),
741+
cx.layout_of(bits_ty),
742742
Size::ZERO,
743743
DIFlags::FlagZero,
744744
type_di_node(cx, bits_ty),
@@ -972,7 +972,7 @@ fn build_field_di_node<'ll, 'tcx>(
972972
cx: &CodegenCx<'ll, 'tcx>,
973973
owner: &'ll DIScope,
974974
name: &str,
975-
size_and_align: (Size, Align),
975+
layout: TyAndLayout<'tcx>,
976976
offset: Size,
977977
flags: DIFlags,
978978
type_di_node: &'ll DIType,
@@ -992,8 +992,8 @@ fn build_field_di_node<'ll, 'tcx>(
992992
name.len(),
993993
file_metadata,
994994
line_number,
995-
size_and_align.0.bits(),
996-
size_and_align.1.bits() as u32,
995+
layout.size.bits(),
996+
layout.align.abi.bits() as u32,
997997
offset.bits(),
998998
flags,
999999
type_di_node,
@@ -1077,7 +1077,7 @@ fn build_struct_type_di_node<'ll, 'tcx>(
10771077
cx,
10781078
owner,
10791079
&field_name[..],
1080-
(field_layout.size, field_layout.align.abi),
1080+
field_layout,
10811081
struct_type_and_layout.fields.offset(i),
10821082
visibility_di_flags(cx, f.did, adt_def.did()),
10831083
type_di_node(cx, field_layout.ty),
@@ -1127,7 +1127,7 @@ fn build_upvar_field_di_nodes<'ll, 'tcx>(
11271127
cx,
11281128
closure_or_coroutine_di_node,
11291129
capture_name.as_str(),
1130-
cx.size_and_align_of(up_var_ty),
1130+
cx.layout_of(up_var_ty),
11311131
layout.fields.offset(index),
11321132
DIFlags::FlagZero,
11331133
type_di_node(cx, up_var_ty),
@@ -1172,7 +1172,7 @@ fn build_tuple_type_di_node<'ll, 'tcx>(
11721172
cx,
11731173
tuple_di_node,
11741174
&tuple_field_name(index),
1175-
cx.size_and_align_of(component_type),
1175+
cx.layout_of(component_type),
11761176
tuple_type_and_layout.fields.offset(index),
11771177
DIFlags::FlagZero,
11781178
type_di_node(cx, component_type),
@@ -1270,7 +1270,7 @@ fn build_union_type_di_node<'ll, 'tcx>(
12701270
cx,
12711271
owner,
12721272
f.name.as_str(),
1273-
size_and_align_of(field_layout),
1273+
field_layout,
12741274
Size::ZERO,
12751275
DIFlags::FlagZero,
12761276
type_di_node(cx, field_layout.ty),
@@ -1418,7 +1418,9 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
14181418
let void_pointer_ty = Ty::new_imm_ptr(tcx, tcx.types.unit);
14191419
let void_pointer_type_di_node = type_di_node(cx, void_pointer_ty);
14201420
let usize_di_node = type_di_node(cx, tcx.types.usize);
1421-
let (pointer_size, pointer_align) = cx.size_and_align_of(void_pointer_ty);
1421+
let pointer_layout = cx.layout_of(void_pointer_ty);
1422+
let pointer_size = pointer_layout.size;
1423+
let pointer_align = pointer_layout.align.abi;
14221424
// If `usize` is not pointer-sized and -aligned then the size and alignment computations
14231425
// for the vtable as a whole would be wrong. Let's make sure this holds even on weird
14241426
// platforms.
@@ -1474,7 +1476,7 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
14741476
cx,
14751477
vtable_type_di_node,
14761478
&field_name,
1477-
(pointer_size, pointer_align),
1479+
pointer_layout,
14781480
field_offset,
14791481
DIFlags::FlagZero,
14801482
field_type_di_node,

‎compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,9 @@ fn build_single_variant_union_fields<'ll, 'tcx>(
370370
cx,
371371
enum_type_di_node,
372372
&variant_union_field_name(variant_index),
373-
// NOTE: We use the size and align of the entire type, not from variant_layout
373+
// NOTE: We use the layout of the entire type, not from variant_layout
374374
// since the later is sometimes smaller (if it has fewer fields).
375-
size_and_align_of(enum_type_and_layout),
375+
enum_type_and_layout,
376376
Size::ZERO,
377377
visibility_flags,
378378
variant_struct_type_wrapper_di_node,
@@ -560,7 +560,7 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
560560
cx,
561561
wrapper_struct_type_di_node,
562562
"value",
563-
size_and_align_of(enum_or_coroutine_type_and_layout),
563+
enum_or_coroutine_type_and_layout,
564564
Size::ZERO,
565565
DIFlags::FlagZero,
566566
variant_struct_type_di_node,
@@ -874,7 +874,7 @@ fn build_union_fields_for_direct_tag_enum_or_coroutine<'ll, 'tcx>(
874874

875875
if is_128_bits {
876876
let type_di_node = type_di_node(cx, cx.tcx.types.u64);
877-
let size_and_align = cx.size_and_align_of(cx.tcx.types.u64);
877+
let u64_layout = cx.layout_of(cx.tcx.types.u64);
878878

879879
let (lo_offset, hi_offset) = match cx.tcx.data_layout.endian {
880880
Endian::Little => (0, 8),
@@ -889,7 +889,7 @@ fn build_union_fields_for_direct_tag_enum_or_coroutine<'ll, 'tcx>(
889889
cx,
890890
enum_type_di_node,
891891
TAG_FIELD_NAME_128_LO,
892-
size_and_align,
892+
u64_layout,
893893
lo_offset,
894894
di_flags,
895895
type_di_node,
@@ -900,7 +900,7 @@ fn build_union_fields_for_direct_tag_enum_or_coroutine<'ll, 'tcx>(
900900
cx,
901901
enum_type_di_node,
902902
TAG_FIELD_NAME_128_HI,
903-
size_and_align,
903+
u64_layout,
904904
hi_offset,
905905
DIFlags::FlagZero,
906906
type_di_node,
@@ -911,7 +911,7 @@ fn build_union_fields_for_direct_tag_enum_or_coroutine<'ll, 'tcx>(
911911
cx,
912912
enum_type_di_node,
913913
TAG_FIELD_NAME,
914-
cx.size_and_align_of(enum_type_and_layout.field(cx, tag_field).ty),
914+
enum_type_and_layout.field(cx, tag_field),
915915
enum_type_and_layout.fields.offset(tag_field),
916916
di_flags,
917917
tag_base_type_di_node,

‎compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ fn build_enum_variant_struct_type_di_node<'ll, 'tcx>(
249249
cx,
250250
struct_type_di_node,
251251
&field_name,
252-
(field_layout.size, field_layout.align.abi),
252+
field_layout,
253253
variant_layout.fields.offset(field_index),
254254
di_flags,
255255
type_di_node(cx, field_layout.ty),
@@ -332,7 +332,7 @@ fn build_coroutine_variant_struct_type_di_node<'ll, 'tcx>(
332332
cx,
333333
variant_struct_type_di_node,
334334
&field_name,
335-
cx.size_and_align_of(field_type),
335+
cx.layout_of(field_type),
336336
variant_layout.fields.offset(field_index),
337337
DIFlags::FlagZero,
338338
type_di_node(cx, field_type),
@@ -352,7 +352,7 @@ fn build_coroutine_variant_struct_type_di_node<'ll, 'tcx>(
352352
cx,
353353
variant_struct_type_di_node,
354354
upvar_name.as_str(),
355-
cx.size_and_align_of(upvar_ty),
355+
cx.layout_of(upvar_ty),
356356
coroutine_type_and_layout.fields.offset(index),
357357
DIFlags::FlagZero,
358358
type_di_node(cx, upvar_ty),

0 commit comments

Comments
 (0)
Failed to load comments.