Skip to content

Commit 5569e6b

Browse files
remove explicit deref of AbiAlign for most methods
Much of the compiler calls functions on Align projected from AbiAlign. AbiAlign impls Deref to its inner Align, so we can simplify these away. Also, it will minimize disruption when AbiAlign is removed. For now, preserve usages that might resolve to PartialOrd or PartialEq, as those have odd inference.
1 parent 2898222 commit 5569e6b

File tree

7 files changed

+12
-14
lines changed

7 files changed

+12
-14
lines changed

src/abi/comments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub(super) fn add_local_place_comments<'tcx>(
8989
format!("{:?}", local),
9090
format!("{:?}", ty),
9191
size.bytes(),
92-
align.abi.bytes(),
92+
align.bytes(),
9393
if extra.is_empty() { "" } else { " " },
9494
extra,
9595
));

src/abi/pass_mode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ pub(super) fn from_casted_value<'tcx>(
233233
// It may also be smaller for example when the type is a wrapper around an integer with a
234234
// larger alignment than the integer.
235235
std::cmp::max(abi_param_size, layout_size),
236-
u32::try_from(layout.align.abi.bytes()).unwrap(),
236+
u32::try_from(layout.align.bytes()).unwrap(),
237237
);
238238
let mut block_params_iter = block_params.iter().copied();
239239
for (offset, _) in abi_params {

src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
846846
let layout = fx.layout_of(fx.monomorphize(ty));
847847
let val = match null_op {
848848
NullOp::SizeOf => layout.size.bytes(),
849-
NullOp::AlignOf => layout.align.abi.bytes(),
849+
NullOp::AlignOf => layout.align.bytes(),
850850
NullOp::OffsetOf(fields) => fx
851851
.tcx
852852
.offset_of_subfield(

src/debuginfo/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl DebugContext {
304304
entry.set(gimli::DW_AT_decl_file, AttributeValue::FileIndex(Some(file_id)));
305305
entry.set(gimli::DW_AT_decl_line, AttributeValue::Udata(line));
306306

307-
entry.set(gimli::DW_AT_alignment, AttributeValue::Udata(static_layout.align.abi.bytes()));
307+
entry.set(gimli::DW_AT_alignment, AttributeValue::Udata(static_layout.align.bytes()));
308308

309309
let mut expr = Expression::new();
310310
expr.op_addr(address_for_data(data_id));

src/debuginfo/types.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl DebugContext {
166166
let tuple_entry = self.dwarf.unit.get_mut(tuple_type_id);
167167
tuple_entry.set(gimli::DW_AT_name, AttributeValue::StringRef(self.dwarf.strings.add(name)));
168168
tuple_entry.set(gimli::DW_AT_byte_size, AttributeValue::Udata(layout.size.bytes()));
169-
tuple_entry.set(gimli::DW_AT_alignment, AttributeValue::Udata(layout.align.abi.bytes()));
169+
tuple_entry.set(gimli::DW_AT_alignment, AttributeValue::Udata(layout.align.bytes()));
170170

171171
for (i, (ty, dw_ty)) in components.into_iter().enumerate() {
172172
let member_id = self.dwarf.unit.add(tuple_type_id, gimli::DW_TAG_member);
@@ -178,9 +178,7 @@ impl DebugContext {
178178
member_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(dw_ty));
179179
member_entry.set(
180180
gimli::DW_AT_alignment,
181-
AttributeValue::Udata(
182-
FullyMonomorphizedLayoutCx(tcx).layout_of(ty).align.abi.bytes(),
183-
),
181+
AttributeValue::Udata(FullyMonomorphizedLayoutCx(tcx).layout_of(ty).align.bytes()),
184182
);
185183
member_entry.set(
186184
gimli::DW_AT_data_member_location,

src/unsize.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub(crate) fn size_and_align_of<'tcx>(
167167
if layout.is_sized() {
168168
return (
169169
fx.bcx.ins().iconst(fx.pointer_type, layout.size.bytes() as i64),
170-
fx.bcx.ins().iconst(fx.pointer_type, layout.align.abi.bytes() as i64),
170+
fx.bcx.ins().iconst(fx.pointer_type, layout.align.bytes() as i64),
171171
);
172172
}
173173

@@ -186,7 +186,7 @@ pub(crate) fn size_and_align_of<'tcx>(
186186
// times the unit size.
187187
(
188188
fx.bcx.ins().imul_imm(info.unwrap(), unit.size.bytes() as i64),
189-
fx.bcx.ins().iconst(fx.pointer_type, unit.align.abi.bytes() as i64),
189+
fx.bcx.ins().iconst(fx.pointer_type, unit.align.bytes() as i64),
190190
)
191191
}
192192
ty::Foreign(_) => {
@@ -224,7 +224,7 @@ pub(crate) fn size_and_align_of<'tcx>(
224224
let unsized_offset_unadjusted = layout.fields.offset(i).bytes();
225225
let unsized_offset_unadjusted =
226226
fx.bcx.ins().iconst(fx.pointer_type, unsized_offset_unadjusted as i64);
227-
let sized_align = layout.align.abi.bytes();
227+
let sized_align = layout.align.bytes();
228228
let sized_align = fx.bcx.ins().iconst(fx.pointer_type, sized_align as i64);
229229

230230
// Recurse to get the size of the dynamically sized field (must be

src/value_and_place.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl<'tcx> CPlace<'tcx> {
383383

384384
let stack_slot = fx.create_stack_slot(
385385
u32::try_from(layout.size.bytes()).unwrap(),
386-
u32::try_from(layout.align.abi.bytes()).unwrap(),
386+
u32::try_from(layout.align.bytes()).unwrap(),
387387
);
388388
CPlace { inner: CPlaceInner::Addr(stack_slot, None), layout }
389389
}
@@ -641,8 +641,8 @@ impl<'tcx> CPlace<'tcx> {
641641
let size = dst_layout.size.bytes();
642642
// `emit_small_memory_copy` uses `u8` for alignments, just use the maximum
643643
// alignment that fits in a `u8` if the actual alignment is larger.
644-
let src_align = src_layout.align.abi.bytes().try_into().unwrap_or(128);
645-
let dst_align = dst_layout.align.abi.bytes().try_into().unwrap_or(128);
644+
let src_align = src_layout.align.bytes().try_into().unwrap_or(128);
645+
let dst_align = dst_layout.align.bytes().try_into().unwrap_or(128);
646646
fx.bcx.emit_small_memory_copy(
647647
fx.target_config,
648648
to_addr,

0 commit comments

Comments
 (0)