Skip to content

Commit dc70fb6

Browse files
committed
also avoid matching on the type in scalar_pair_element_llvm_type
1 parent 0fde82f commit dc70fb6

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

compiler/rustc_codegen_llvm/src/type_of.rs

+3-21
Original file line numberDiff line numberDiff line change
@@ -299,27 +299,9 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
299299
index: usize,
300300
immediate: bool,
301301
) -> &'a Type {
302-
// HACK(eddyb) special-case fat pointers until LLVM removes
303-
// pointee types, to avoid bitcasting every `OperandRef::deref`.
304-
match *self.ty.kind() {
305-
ty::Ref(..) | ty::RawPtr(_) => {
306-
return self.field(cx, index).llvm_type(cx);
307-
}
308-
// only wide pointer boxes are handled as pointers
309-
// thin pointer boxes with scalar allocators are handled by the general logic below
310-
ty::Adt(def, args) if def.is_box() && cx.layout_of(args.type_at(1)).is_zst() => {
311-
let ptr_ty = Ty::new_mut_ptr(cx.tcx, self.ty.boxed_ty());
312-
return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate);
313-
}
314-
// `dyn* Trait` has the same ABI as `*mut dyn Trait`
315-
ty::Dynamic(bounds, region, ty::DynStar) => {
316-
let ptr_ty =
317-
Ty::new_mut_ptr(cx.tcx, Ty::new_dynamic(cx.tcx, bounds, region, ty::Dyn));
318-
return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate);
319-
}
320-
_ => {}
321-
}
322-
302+
// This must produce the same result for `repr(transparent)` wrappers as for the inner type!
303+
// In other words, this should generally not look at the type at all, but only at the
304+
// layout.
323305
let Abi::ScalarPair(a, b) = self.abi else {
324306
bug!("TyAndLayout::scalar_pair_element_llty({:?}): not applicable", self);
325307
};

0 commit comments

Comments
 (0)