@@ -180,7 +180,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
180180 }
181181
182182 _ => {
183- assert ! ( self . rvalue_creates_operand( rvalue) ) ;
184183 let temp = self . codegen_rvalue_operand ( bx, rvalue) ;
185184 temp. val . store ( bx, dest) ;
186185 }
@@ -218,11 +217,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
218217
219218 /// Transmutes an `OperandValue` to another `OperandValue`.
220219 ///
221- /// This is supported only for cases where [`Self::rvalue_creates_operand`]
222- /// returns `true`, and will ICE otherwise. (In particular, anything that
223- /// would need to `alloca` in order to return a `PlaceValue` will ICE,
224- /// expecting those to go via [`Self::codegen_transmute`] instead where
225- /// the destination place is already allocated.)
220+ /// This is supported for all cases where the `cast` type is SSA,
221+ /// but for non-ZSTs with [`abi::BackendRepr::Memory`] it ICEs.
226222 pub ( crate ) fn codegen_transmute_operand (
227223 & mut self ,
228224 bx : & mut Bx ,
@@ -379,8 +375,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
379375 bx : & mut Bx ,
380376 rvalue : & mir:: Rvalue < ' tcx > ,
381377 ) -> OperandRef < ' tcx , Bx :: Value > {
382- assert ! ( self . rvalue_creates_operand( rvalue) , "cannot codegen {rvalue:?} to operand" , ) ;
383-
384378 match * rvalue {
385379 mir:: Rvalue :: Cast ( ref kind, ref source, mir_cast_ty) => {
386380 let operand = self . codegen_operand ( bx, source) ;
@@ -706,8 +700,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
706700 let ty = self . monomorphize ( ty) ;
707701 let layout = self . cx . layout_of ( ty) ;
708702
709- // `rvalue_creates_operand` has arranged that we only get here if
710- // we can build the aggregate immediate from the field immediates.
711703 let mut builder = OperandRefBuilder :: new ( layout) ;
712704 for ( field_idx, field) in fields. iter_enumerated ( ) {
713705 let op = self . codegen_operand ( bx, field) ;
@@ -1008,38 +1000,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10081000
10091001 OperandValue :: Pair ( val, of)
10101002 }
1011-
1012- /// Returns `true` if the `rvalue` can be computed into an [`OperandRef`],
1013- /// rather than needing a full `PlaceRef` for the assignment destination.
1014- ///
1015- /// This is used by the [`super::analyze`] code to decide which MIR locals
1016- /// can stay as SSA values (as opposed to generating `alloca` slots for them).
1017- /// As such, some paths here return `true` even where the specific rvalue
1018- /// will not actually take the operand path because the result type is such
1019- /// that it always gets an `alloca`, but where it's not worth re-checking the
1020- /// layout in this code when the right thing will happen anyway.
1021- pub ( crate ) fn rvalue_creates_operand ( & self , rvalue : & mir:: Rvalue < ' tcx > ) -> bool {
1022- match * rvalue {
1023- mir:: Rvalue :: Ref ( ..) |
1024- mir:: Rvalue :: CopyForDeref ( ..) |
1025- mir:: Rvalue :: RawPtr ( ..) |
1026- mir:: Rvalue :: Len ( ..) |
1027- mir:: Rvalue :: Cast ( ..) | // (*)
1028- mir:: Rvalue :: ShallowInitBox ( ..) | // (*)
1029- mir:: Rvalue :: BinaryOp ( ..) |
1030- mir:: Rvalue :: UnaryOp ( ..) |
1031- mir:: Rvalue :: Discriminant ( ..) |
1032- mir:: Rvalue :: NullaryOp ( ..) |
1033- mir:: Rvalue :: ThreadLocalRef ( _) |
1034- mir:: Rvalue :: Use ( ..) |
1035- mir:: Rvalue :: Repeat ( ..) | // (*)
1036- mir:: Rvalue :: Aggregate ( ..) | // (*)
1037- mir:: Rvalue :: WrapUnsafeBinder ( ..) => // (*)
1038- true ,
1039- }
1040-
1041- // (*) this is only true if the type is suitable
1042- }
10431003}
10441004
10451005/// Transmutes a single scalar value `imm` from `from_scalar` to `to_scalar`.
0 commit comments