@@ -12,7 +12,7 @@ use crate::MemFlags;
1212use rustc_ast as ast;
1313use rustc_ast:: { InlineAsmOptions , InlineAsmTemplatePiece } ;
1414use rustc_hir:: lang_items:: LangItem ;
15- use rustc_middle:: mir:: { self , AssertKind , SwitchTargets , UnwindTerminateReason } ;
15+ use rustc_middle:: mir:: { self , AssertKind , BasicBlock , SwitchTargets , UnwindTerminateReason } ;
1616use rustc_middle:: ty:: layout:: { HasTyCtxt , LayoutOf , ValidityRequirement } ;
1717use rustc_middle:: ty:: print:: { with_no_trimmed_paths, with_no_visible_paths} ;
1818use rustc_middle:: ty:: { self , Instance , Ty } ;
@@ -824,8 +824,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
824824 self . get_caller_location ( bx, mir:: SourceInfo { span : fn_span, ..source_info } ) ;
825825
826826 let mut llargs = Vec :: with_capacity ( arg_count) ;
827- let ret_dest =
828- self . make_return_dest ( bx, destination, & fn_abi. ret , & mut llargs, true , true ) ;
827+ let ret_dest = self . make_return_dest (
828+ bx,
829+ destination,
830+ & fn_abi. ret ,
831+ & mut llargs,
832+ intrinsic,
833+ Some ( target) ,
834+ ) ;
829835 assert_eq ! ( llargs, [ ] ) ;
830836 if let ReturnDest :: IndirectOperand ( tmp, _) = ret_dest {
831837 location. val . store ( bx, tmp) ;
@@ -846,8 +852,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
846852 destination,
847853 & fn_abi. ret ,
848854 & mut llargs,
849- true ,
850- target. is_some ( ) ,
855+ Some ( intrinsic ) ,
856+ target,
851857 ) ;
852858 let dest = match ret_dest {
853859 _ if fn_abi. ret . is_indirect ( ) => llargs[ 0 ] ,
@@ -912,7 +918,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
912918
913919 let mut llargs = Vec :: with_capacity ( arg_count) ;
914920 let destination = target. as_ref ( ) . map ( |& target| {
915- ( self . make_return_dest ( bx, destination, & fn_abi. ret , & mut llargs, false , true ) , target)
921+ (
922+ self . make_return_dest (
923+ bx,
924+ destination,
925+ & fn_abi. ret ,
926+ & mut llargs,
927+ None ,
928+ Some ( target) ,
929+ ) ,
930+ target,
931+ )
916932 } ) ;
917933
918934 // Split the rust-call tupled arguments off.
@@ -1645,10 +1661,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
16451661 dest : mir:: Place < ' tcx > ,
16461662 fn_ret : & ArgAbi < ' tcx , Ty < ' tcx > > ,
16471663 llargs : & mut Vec < Bx :: Value > ,
1648- is_intrinsic : bool ,
1649- has_target : bool ,
1664+ intrinsic : Option < ty :: IntrinsicDef > ,
1665+ target : Option < BasicBlock > ,
16501666 ) -> ReturnDest < ' tcx , Bx :: Value > {
1651- if !has_target {
1667+ if target . is_none ( ) {
16521668 return ReturnDest :: Nothing ;
16531669 }
16541670 // If the return is ignored, we can just return a do-nothing `ReturnDest`.
@@ -1669,7 +1685,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
16691685 tmp. storage_live ( bx) ;
16701686 llargs. push ( tmp. llval ) ;
16711687 ReturnDest :: IndirectOperand ( tmp, index)
1672- } else if is_intrinsic {
1688+ } else if intrinsic . is_some ( ) {
16731689 // Currently, intrinsics always need a location to store
16741690 // the result, so we create a temporary `alloca` for the
16751691 // result.
0 commit comments