@@ -9,7 +9,7 @@ use crate::MemFlags;
9
9
10
10
use rustc_hir as hir;
11
11
use rustc_middle:: mir;
12
- use rustc_middle:: mir:: Operand ;
12
+ use rustc_middle:: mir:: { AggregateKind , Operand } ;
13
13
use rustc_middle:: ty:: cast:: { CastTy , IntTy } ;
14
14
use rustc_middle:: ty:: layout:: { HasTyCtxt , LayoutOf , TyAndLayout } ;
15
15
use rustc_middle:: ty:: { self , adjustment:: PointerCoercion , Instance , Ty , TyCtxt } ;
@@ -717,6 +717,24 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
717
717
OperandRef { val : OperandValue :: Immediate ( static_) , layout }
718
718
}
719
719
mir:: Rvalue :: Use ( ref operand) => self . codegen_operand ( bx, operand) ,
720
+ mir:: Rvalue :: Aggregate ( box mir:: AggregateKind :: RawPtr ( ..) , ref fields) => {
721
+ let ty = rvalue. ty ( self . mir , self . cx . tcx ( ) ) ;
722
+ let layout = self . cx . layout_of ( self . monomorphize ( ty) ) ;
723
+ let [ data, meta] = & * fields. raw else {
724
+ bug ! ( "RawPtr fields: {fields:?}" ) ;
725
+ } ;
726
+ let data = self . codegen_operand ( bx, data) ;
727
+ let meta = self . codegen_operand ( bx, meta) ;
728
+ match ( data. val , meta. val ) {
729
+ ( p @ OperandValue :: Immediate ( _) , OperandValue :: ZeroSized ) => {
730
+ OperandRef { val : p, layout }
731
+ }
732
+ ( OperandValue :: Immediate ( p) , OperandValue :: Immediate ( m) ) => {
733
+ OperandRef { val : OperandValue :: Pair ( p, m) , layout }
734
+ }
735
+ _ => bug ! ( "RawPtr operands {data:?} {meta:?}" ) ,
736
+ }
737
+ }
720
738
mir:: Rvalue :: Repeat ( ..) | mir:: Rvalue :: Aggregate ( ..) => {
721
739
// According to `rvalue_creates_operand`, only ZST
722
740
// aggregate rvalues are allowed to be operands.
@@ -1029,6 +1047,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1029
1047
mir:: Rvalue :: ThreadLocalRef ( _) |
1030
1048
mir:: Rvalue :: Use ( ..) => // (*)
1031
1049
true ,
1050
+ // This always produces a `ty::RawPtr`, so will be Immediate or Pair
1051
+ mir:: Rvalue :: Aggregate ( box AggregateKind :: RawPtr ( ..) , ..) => true ,
1032
1052
mir:: Rvalue :: Repeat ( ..) |
1033
1053
mir:: Rvalue :: Aggregate ( ..) => {
1034
1054
let ty = rvalue. ty ( self . mir , self . cx . tcx ( ) ) ;
0 commit comments