@@ -16,9 +16,9 @@ use tracing::{debug, instrument};
1616use super :: place:: { PlaceRef , PlaceValue } ;
1717use super :: rvalue:: transmute_scalar;
1818use super :: { FunctionCx , LocalRef } ;
19+ use crate :: MemFlags ;
1920use crate :: common:: IntPredicate ;
2021use crate :: traits:: * ;
21- use crate :: { MemFlags , size_of_val} ;
2222
2323/// The representation of a Rust value. The enum variant is in fact
2424/// uniquely determined by the value's type, but is kept as a
@@ -861,44 +861,6 @@ impl<'a, 'tcx, V: CodegenObject> OperandValue<V> {
861861 }
862862 }
863863 }
864-
865- pub fn store_unsized < Bx : BuilderMethods < ' a , ' tcx , Value = V > > (
866- self ,
867- bx : & mut Bx ,
868- indirect_dest : PlaceRef < ' tcx , V > ,
869- ) {
870- debug ! ( "OperandRef::store_unsized: operand={:?}, indirect_dest={:?}" , self , indirect_dest) ;
871- // `indirect_dest` must have `*mut T` type. We extract `T` out of it.
872- let unsized_ty = indirect_dest
873- . layout
874- . ty
875- . builtin_deref ( true )
876- . unwrap_or_else ( || bug ! ( "indirect_dest has non-pointer type: {:?}" , indirect_dest) ) ;
877-
878- let OperandValue :: Ref ( PlaceValue { llval : llptr, llextra : Some ( llextra) , .. } ) = self
879- else {
880- bug ! ( "store_unsized called with a sized value (or with an extern type)" )
881- } ;
882-
883- // Allocate an appropriate region on the stack, and copy the value into it. Since alloca
884- // doesn't support dynamic alignment, we allocate an extra align - 1 bytes, and align the
885- // pointer manually.
886- let ( size, align) = size_of_val:: size_and_align_of_dst ( bx, unsized_ty, Some ( llextra) ) ;
887- let one = bx. const_usize ( 1 ) ;
888- let align_minus_1 = bx. sub ( align, one) ;
889- let size_extra = bx. add ( size, align_minus_1) ;
890- let min_align = Align :: ONE ;
891- let alloca = bx. dynamic_alloca ( size_extra, min_align) ;
892- let address = bx. ptrtoint ( alloca, bx. type_isize ( ) ) ;
893- let neg_address = bx. neg ( address) ;
894- let offset = bx. and ( neg_address, align_minus_1) ;
895- let dst = bx. inbounds_ptradd ( alloca, offset) ;
896- bx. memcpy ( dst, min_align, llptr, min_align, size, MemFlags :: empty ( ) ) ;
897-
898- // Store the allocated region and the extra to the indirect place.
899- let indirect_operand = OperandValue :: Pair ( dst, llextra) ;
900- indirect_operand. store ( bx, indirect_dest) ;
901- }
902864}
903865
904866impl < ' a , ' tcx , Bx : BuilderMethods < ' a , ' tcx > > FunctionCx < ' a , ' tcx , Bx > {
0 commit comments