Skip to content

Commit a4cb6e7

Browse files
committed
Carry the b_offset inside BackendRepr::ScalarPair
1 parent 382936a commit a4cb6e7

3 files changed

Lines changed: 10 additions & 11 deletions

File tree

src/builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,9 +1064,9 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
10641064
load
10651065
},
10661066
)
1067-
} else if let abi::BackendRepr::ScalarPair(ref a, ref b) = place.layout.backend_repr {
1068-
let b_offset = a.size(self).align_to(b.default_align(self).abi);
1069-
1067+
} else if let abi::BackendRepr::ScalarPair { ref a, ref b, b_offset } =
1068+
place.layout.backend_repr
1069+
{
10701070
let mut load = |i, scalar: &abi::Scalar, align| {
10711071
let ptr = if i == 0 {
10721072
place.val.llval

src/intrinsic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
485485
let tp_ty = fn_args.type_at(0);
486486
let layout = self.layout_of(tp_ty).layout;
487487
let _use_integer_compare = match layout.backend_repr() {
488-
Scalar(_) | ScalarPair(_, _) => true,
488+
Scalar(_) | ScalarPair { a: _, b: _, b_offset: _ } => true,
489489
SimdVector { .. } | SimdScalableVector { .. } => false,
490490
Memory { .. } => {
491491
// For rusty ABIs, small aggregates are actually passed

src/type_of.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn uncached_gcc_type<'gcc, 'tcx>(
7575
};
7676
return cx.context.new_vector_type(element, count);
7777
}
78-
BackendRepr::ScalarPair(..) => {
78+
BackendRepr::ScalarPair { .. } => {
7979
return cx.type_struct(
8080
&[
8181
layout.scalar_pair_element_gcc_type(cx, 0),
@@ -182,13 +182,13 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
182182
BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } => true,
183183
// FIXME(rustc_scalable_vector): Not yet implemented in rustc_codegen_gcc.
184184
BackendRepr::SimdScalableVector { .. } => todo!(),
185-
BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => false,
185+
BackendRepr::ScalarPair { .. } | BackendRepr::Memory { .. } => false,
186186
}
187187
}
188188

189189
fn is_gcc_scalar_pair(&self) -> bool {
190190
match self.backend_repr {
191-
BackendRepr::ScalarPair(..) => true,
191+
BackendRepr::ScalarPair { .. } => true,
192192
BackendRepr::Scalar(_)
193193
| BackendRepr::SimdVector { .. }
194194
| BackendRepr::SimdScalableVector { .. }
@@ -308,8 +308,8 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
308308
// This must produce the same result for `repr(transparent)` wrappers as for the inner type!
309309
// In other words, this should generally not look at the type at all, but only at the
310310
// layout.
311-
let (a, b) = match self.backend_repr {
312-
BackendRepr::ScalarPair(ref a, ref b) => (a, b),
311+
let (a, b, b_offset) = match self.backend_repr {
312+
BackendRepr::ScalarPair { ref a, ref b, b_offset } => (a, b, b_offset),
313313
_ => bug!("TyAndLayout::scalar_pair_element_llty({:?}): not applicable", self),
314314
};
315315
let scalar = [a, b][index];
@@ -325,8 +325,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
325325
return cx.type_i1();
326326
}
327327

328-
let offset =
329-
if index == 0 { Size::ZERO } else { a.size(cx).align_to(b.default_align(cx).abi) };
328+
let offset = if index == 0 { Size::ZERO } else { b_offset };
330329
self.scalar_gcc_type_at(cx, scalar, offset)
331330
}
332331

0 commit comments

Comments
 (0)