@@ -56,23 +56,22 @@ pub(super) fn codegen_return_param<'tcx>(
5656pub ( super )  fn  codegen_with_call_return_arg < ' tcx > ( 
5757    fx :  & mut  FunctionCx < ' _ ,  ' _ ,  ' tcx > , 
5858    ret_arg_abi :  & ArgAbi < ' tcx ,  Ty < ' tcx > > , 
59-     ret_place :  Option < CPlace < ' tcx > > , 
59+     ret_place :  CPlace < ' tcx > , 
6060    f :  impl  FnOnce ( & mut  FunctionCx < ' _ ,  ' _ ,  ' tcx > ,  Option < Value > )  -> Inst , 
6161)  { 
6262    let  ( ret_temp_place,  return_ptr)  = match  ret_arg_abi. mode  { 
6363        PassMode :: Ignore  => ( None ,  None ) , 
64-         PassMode :: Indirect  {  attrs :  _,  extra_attrs :  None ,  on_stack :  _ }  => match  ret_place  { 
65-             Some ( ret_place )   if  matches ! ( ret_place. inner( ) ,  CPlaceInner :: Addr ( _,  None ) )  =>  { 
64+         PassMode :: Indirect  {  attrs :  _,  extra_attrs :  None ,  on_stack :  _ }  => { 
65+             if  matches ! ( ret_place. inner( ) ,  CPlaceInner :: Addr ( _,  None ) )  { 
6666                // This is an optimization to prevent unnecessary copies of the return value when 
6767                // the return place is already a memory place as opposed to a register. 
6868                // This match arm can be safely removed. 
6969                ( None ,  Some ( ret_place. to_ptr ( ) . get_addr ( fx) ) ) 
70-             } 
71-             _ => { 
70+             }  else  { 
7271                let  place = CPlace :: new_stack_slot ( fx,  ret_arg_abi. layout ) ; 
7372                ( Some ( place) ,  Some ( place. to_ptr ( ) . get_addr ( fx) ) ) 
7473            } 
75-         } , 
74+         } 
7675        PassMode :: Indirect  {  attrs :  _,  extra_attrs :  Some ( _) ,  on_stack :  _ }  => { 
7776            unreachable ! ( "unsized return value" ) 
7877        } 
@@ -84,39 +83,25 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
8483    match  ret_arg_abi. mode  { 
8584        PassMode :: Ignore  => { } 
8685        PassMode :: Direct ( _)  => { 
87-             if  let  Some ( ret_place)  = ret_place { 
88-                 let  ret_val = fx. bcx . inst_results ( call_inst) [ 0 ] ; 
89-                 ret_place. write_cvalue ( fx,  CValue :: by_val ( ret_val,  ret_arg_abi. layout ) ) ; 
90-             } 
86+             let  ret_val = fx. bcx . inst_results ( call_inst) [ 0 ] ; 
87+             ret_place. write_cvalue ( fx,  CValue :: by_val ( ret_val,  ret_arg_abi. layout ) ) ; 
9188        } 
9289        PassMode :: Pair ( _,  _)  => { 
93-             if  let  Some ( ret_place)  = ret_place { 
94-                 let  ret_val_a = fx. bcx . inst_results ( call_inst) [ 0 ] ; 
95-                 let  ret_val_b = fx. bcx . inst_results ( call_inst) [ 1 ] ; 
96-                 ret_place. write_cvalue ( 
97-                     fx, 
98-                     CValue :: by_val_pair ( ret_val_a,  ret_val_b,  ret_arg_abi. layout ) , 
99-                 ) ; 
100-             } 
90+             let  ret_val_a = fx. bcx . inst_results ( call_inst) [ 0 ] ; 
91+             let  ret_val_b = fx. bcx . inst_results ( call_inst) [ 1 ] ; 
92+             ret_place
93+                 . write_cvalue ( fx,  CValue :: by_val_pair ( ret_val_a,  ret_val_b,  ret_arg_abi. layout ) ) ; 
10194        } 
10295        PassMode :: Cast ( cast)  => { 
103-             if  let  Some ( ret_place)  = ret_place { 
104-                 let  results = fx
105-                     . bcx 
106-                     . inst_results ( call_inst) 
107-                     . iter ( ) 
108-                     . copied ( ) 
109-                     . collect :: < SmallVec < [ Value ;  2 ] > > ( ) ; 
110-                 let  result =
111-                     super :: pass_mode:: from_casted_value ( fx,  & results,  ret_place. layout ( ) ,  cast) ; 
112-                 ret_place. write_cvalue ( fx,  result) ; 
113-             } 
96+             let  results =
97+                 fx. bcx . inst_results ( call_inst) . iter ( ) . copied ( ) . collect :: < SmallVec < [ Value ;  2 ] > > ( ) ; 
98+             let  result =
99+                 super :: pass_mode:: from_casted_value ( fx,  & results,  ret_place. layout ( ) ,  cast) ; 
100+             ret_place. write_cvalue ( fx,  result) ; 
114101        } 
115102        PassMode :: Indirect  {  attrs :  _,  extra_attrs :  None ,  on_stack :  _ }  => { 
116-             if  let  ( Some ( ret_place) ,  Some ( ret_temp_place) )  = ( ret_place,  ret_temp_place)  { 
117-                 // Both ret_place and ret_temp_place must be Some. If ret_place is None, this is 
118-                 // a non-returning call. If ret_temp_place is None, it is not necessary to copy the 
119-                 // return value. 
103+             if  let  Some ( ret_temp_place)  = ret_temp_place { 
104+                 // If ret_temp_place is None, it is not necessary to copy the return value. 
120105                let  ret_temp_value = ret_temp_place. to_cvalue ( fx) ; 
121106                ret_place. write_cvalue ( fx,  ret_temp_value) ; 
122107            } 
0 commit comments