diff options
| author | Michael Goulet <michael@errs.io> | 2023-02-15 03:42:45 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-02-18 19:47:34 +0000 |
| commit | e82cc656c822af7f1905b757a27cac5823fbc301 (patch) | |
| tree | 6126aa215982fa90c2540f4666818ea115a72ae3 /compiler/rustc_codegen_llvm/src | |
| parent | 1f11d841b5748133c2d51da0001fc88bc6b51e78 (diff) | |
| download | rust-e82cc656c822af7f1905b757a27cac5823fbc301.tar.gz rust-e82cc656c822af7f1905b757a27cac5823fbc301.zip | |
Make dyn* have the same scalar pair ABI as corresponding fat pointer
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/type_of.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index cc8ff947fc3..9cda24bab87 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -329,7 +329,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { ) -> &'a Type { // HACK(eddyb) special-case fat pointers until LLVM removes // pointee types, to avoid bitcasting every `OperandRef::deref`. - match self.ty.kind() { + match *self.ty.kind() { ty::Ref(..) | ty::RawPtr(_) => { return self.field(cx, index).llvm_type(cx); } @@ -339,6 +339,11 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { let ptr_ty = cx.tcx.mk_mut_ptr(self.ty.boxed_ty()); return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate); } + // `dyn* Trait` has the same ABI as `*mut dyn Trait` + ty::Dynamic(bounds, region, ty::DynStar) => { + let ptr_ty = cx.tcx.mk_mut_ptr(cx.tcx.mk_dynamic(bounds, region, ty::Dyn)); + return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate); + } _ => {} } |
