@@ -186,7 +186,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
186186
187187 // Allocate variable and temp allocas
188188 fx. locals = {
189- let args = arg_local_refs ( & mut bx, & fx, & memory_locals) ;
189+ let args = arg_local_refs ( & mut bx, & mut fx, & memory_locals) ;
190190
191191 let mut allocate_local = |local| {
192192 let decl = & mir. local_decls [ local] ;
@@ -328,14 +328,14 @@ fn create_funclets<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
328328/// indirect.
329329fn arg_local_refs < ' a , ' tcx , Bx : BuilderMethods < ' a , ' tcx > > (
330330 bx : & mut Bx ,
331- fx : & FunctionCx < ' a , ' tcx , Bx > ,
331+ fx : & mut FunctionCx < ' a , ' tcx , Bx > ,
332332 memory_locals : & BitSet < mir:: Local > ,
333333) -> Vec < LocalRef < ' tcx , Bx :: Value > > {
334334 let mir = fx. mir ;
335335 let mut idx = 0 ;
336336 let mut llarg_idx = fx. fn_abi . ret . is_indirect ( ) as usize ;
337337
338- mir. args_iter ( ) . enumerate ( ) . map ( |( arg_index, local) | {
338+ let args = mir. args_iter ( ) . enumerate ( ) . map ( |( arg_index, local) | {
339339 let arg_decl = & mir. local_decls [ local] ;
340340
341341 if Some ( local) == mir. spread_arg {
@@ -431,7 +431,16 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
431431 bx. store_fn_arg ( arg, & mut llarg_idx, tmp) ;
432432 LocalRef :: Place ( tmp)
433433 }
434- } ) . collect ( )
434+ } ) . collect ( ) ;
435+
436+ if fx. instance . def . requires_caller_location ( bx. tcx ( ) ) {
437+ let arg = & fx. fn_abi . args . last ( ) . unwrap ( ) ;
438+ let place = PlaceRef :: alloca ( bx, arg. layout ) ;
439+ bx. store_fn_arg ( arg, & mut llarg_idx, place) ;
440+ fx. caller_location = Some ( place) ;
441+ }
442+
443+ args
435444}
436445
437446mod analyze;
0 commit comments