1+ //! Return value handling
2+
13use crate :: abi:: pass_mode:: * ;
24use crate :: prelude:: * ;
35
46fn return_layout < ' a , ' tcx > ( fx : & mut FunctionCx < ' a , ' tcx , impl Backend > ) -> TyAndLayout < ' tcx > {
57 fx. layout_of ( fx. monomorphize ( & fx. mir . local_decls [ RETURN_PLACE ] . ty ) )
68}
79
10+ /// Can the given type be returned into an ssa var or does it need to be returned on the stack.
811pub ( crate ) fn can_return_to_ssa_var < ' tcx > (
912 tcx : TyCtxt < ' tcx > ,
1013 dest_layout : TyAndLayout < ' tcx > ,
@@ -16,6 +19,8 @@ pub(crate) fn can_return_to_ssa_var<'tcx>(
1619 }
1720}
1821
22+ /// Return a place where the return value of the current function can be written to. If necessary
23+ /// this adds an extra parameter pointing to where the return value needs to be stored.
1924pub ( super ) fn codegen_return_param < ' tcx > (
2025 fx : & mut FunctionCx < ' _ , ' tcx , impl Backend > ,
2126 ssa_analyzed : & rustc_index:: vec:: IndexVec < Local , crate :: analyze:: SsaKind > ,
@@ -59,6 +64,8 @@ pub(super) fn codegen_return_param<'tcx>(
5964 ret_place
6065}
6166
67+ /// Invokes the closure with if necessary a value representing the return pointer. When the closure
68+ /// returns the call return value(s) if any are written to the correct place.
6269pub ( super ) fn codegen_with_call_return_arg < ' tcx , B : Backend , T > (
6370 fx : & mut FunctionCx < ' _ , ' tcx , B > ,
6471 fn_sig : FnSig < ' tcx > ,
@@ -102,6 +109,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>(
102109 ( call_inst, meta)
103110}
104111
112+ /// Codegen a return instruction with the right return value(s) if any.
105113pub ( crate ) fn codegen_return ( fx : & mut FunctionCx < ' _ , ' _ , impl Backend > ) {
106114 match get_pass_mode ( fx. tcx , return_layout ( fx) ) {
107115 PassMode :: NoPass | PassMode :: ByRef { size : Some ( _) } => {
0 commit comments