@@ -9,7 +9,7 @@ use crate::MemFlags;
99
1010use rustc_hir as hir;
1111use rustc_middle:: mir;
12- use rustc_middle:: mir:: Operand ;
12+ use rustc_middle:: mir:: { AggregateKind , Operand } ;
1313use rustc_middle:: ty:: cast:: { CastTy , IntTy } ;
1414use rustc_middle:: ty:: layout:: { HasTyCtxt , LayoutOf , TyAndLayout } ;
1515use rustc_middle:: ty:: { self , adjustment:: PointerCoercion , Instance , Ty , TyCtxt } ;
@@ -720,6 +720,24 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
720720 OperandRef { val : OperandValue :: Immediate ( static_) , layout }
721721 }
722722 mir:: Rvalue :: Use ( ref operand) => self . codegen_operand ( bx, operand) ,
723+ mir:: Rvalue :: Aggregate ( box mir:: AggregateKind :: RawPtr ( ..) , ref fields) => {
724+ let ty = rvalue. ty ( self . mir , self . cx . tcx ( ) ) ;
725+ let layout = self . cx . layout_of ( self . monomorphize ( ty) ) ;
726+ let [ data, meta] = & * fields. raw else {
727+ bug ! ( "RawPtr fields: {fields:?}" ) ;
728+ } ;
729+ let data = self . codegen_operand ( bx, data) ;
730+ let meta = self . codegen_operand ( bx, meta) ;
731+ match ( data. val , meta. val ) {
732+ ( p @ OperandValue :: Immediate ( _) , OperandValue :: ZeroSized ) => {
733+ OperandRef { val : p, layout }
734+ }
735+ ( OperandValue :: Immediate ( p) , OperandValue :: Immediate ( m) ) => {
736+ OperandRef { val : OperandValue :: Pair ( p, m) , layout }
737+ }
738+ _ => bug ! ( "RawPtr operands {data:?} {meta:?}" ) ,
739+ }
740+ }
723741 mir:: Rvalue :: Repeat ( ..) | mir:: Rvalue :: Aggregate ( ..) => {
724742 // According to `rvalue_creates_operand`, only ZST
725743 // aggregate rvalues are allowed to be operands.
@@ -1032,6 +1050,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10321050 mir:: Rvalue :: ThreadLocalRef ( _) |
10331051 mir:: Rvalue :: Use ( ..) => // (*)
10341052 true ,
1053+ // This always produces a `ty::RawPtr`, so will be Immediate or Pair
1054+ mir:: Rvalue :: Aggregate ( box AggregateKind :: RawPtr ( ..) , ..) => true ,
10351055 mir:: Rvalue :: Repeat ( ..) |
10361056 mir:: Rvalue :: Aggregate ( ..) => {
10371057 let ty = rvalue. ty ( self . mir , self . cx . tcx ( ) ) ;
0 commit comments