@@ -548,10 +548,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
548548 }
549549 TerminatorKind :: Drop { place, target, unwind : _, replace : _ } => {
550550 let drop_place = codegen_place ( fx, * place) ;
551- crate :: abi:: codegen_drop ( fx, source_info, drop_place) ;
552-
553- let target_block = fx. get_block ( * target) ;
554- fx. bcx . ins ( ) . jump ( target_block, & [ ] ) ;
551+ crate :: abi:: codegen_drop ( fx, source_info, drop_place, * target) ;
555552 }
556553 } ;
557554 }
@@ -619,22 +616,34 @@ fn codegen_stmt<'tcx>(
619616 Rvalue :: UnaryOp ( un_op, ref operand) => {
620617 let operand = codegen_operand ( fx, operand) ;
621618 let layout = operand. layout ( ) ;
622- let val = operand. load_scalar ( fx) ;
623619 let res = match un_op {
624- UnOp :: Not => match layout. ty . kind ( ) {
625- ty:: Bool => {
626- let res = fx. bcx . ins ( ) . icmp_imm ( IntCC :: Equal , val, 0 ) ;
627- CValue :: by_val ( res, layout)
620+ UnOp :: Not => {
621+ let val = operand. load_scalar ( fx) ;
622+ match layout. ty . kind ( ) {
623+ ty:: Bool => {
624+ let res = fx. bcx . ins ( ) . icmp_imm ( IntCC :: Equal , val, 0 ) ;
625+ CValue :: by_val ( res, layout)
626+ }
627+ ty:: Uint ( _) | ty:: Int ( _) => {
628+ CValue :: by_val ( fx. bcx . ins ( ) . bnot ( val) , layout)
629+ }
630+ _ => unreachable ! ( "un op Not for {:?}" , layout. ty) ,
628631 }
629- ty:: Uint ( _) | ty:: Int ( _) => {
630- CValue :: by_val ( fx. bcx . ins ( ) . bnot ( val) , layout)
632+ }
633+ UnOp :: Neg => {
634+ let val = operand. load_scalar ( fx) ;
635+ match layout. ty . kind ( ) {
636+ ty:: Int ( _) => CValue :: by_val ( fx. bcx . ins ( ) . ineg ( val) , layout) ,
637+ ty:: Float ( _) => CValue :: by_val ( fx. bcx . ins ( ) . fneg ( val) , layout) ,
638+ _ => unreachable ! ( "un op Neg for {:?}" , layout. ty) ,
631639 }
632- _ => unreachable ! ( "un op Not for {:?}" , layout. ty) ,
633- } ,
634- UnOp :: Neg => match layout. ty . kind ( ) {
635- ty:: Int ( _) => CValue :: by_val ( fx. bcx . ins ( ) . ineg ( val) , layout) ,
636- ty:: Float ( _) => CValue :: by_val ( fx. bcx . ins ( ) . fneg ( val) , layout) ,
637- _ => unreachable ! ( "un op Neg for {:?}" , layout. ty) ,
640+ }
641+ UnOp :: PtrMetadata => match layout. abi {
642+ Abi :: Scalar ( _) => CValue :: zst ( dest_layout) ,
643+ Abi :: ScalarPair ( _, _) => {
644+ CValue :: by_val ( operand. load_scalar_pair ( fx) . 1 , dest_layout)
645+ }
646+ _ => bug ! ( "Unexpected `PtrToMetadata` operand: {operand:?}" ) ,
638647 } ,
639648 } ;
640649 lval. write_cvalue ( fx, res) ;
0 commit comments