@@ -182,7 +182,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
182182
183183 // Allocate variable and temp allocas
184184 fx. locals = {
185- let args = arg_local_refs ( & mut bx, & fx, & memory_locals) ;
185+ let args = arg_local_refs ( & mut bx, & mut fx, & memory_locals) ;
186186
187187 let mut allocate_local = |local| {
188188 let decl = & mir_body. local_decls [ local] ;
@@ -324,14 +324,14 @@ fn create_funclets<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
324324/// indirect.
325325fn arg_local_refs < ' a , ' tcx , Bx : BuilderMethods < ' a , ' tcx > > (
326326 bx : & mut Bx ,
327- fx : & FunctionCx < ' a , ' tcx , Bx > ,
327+ fx : & mut FunctionCx < ' a , ' tcx , Bx > ,
328328 memory_locals : & BitSet < mir:: Local > ,
329329) -> Vec < LocalRef < ' tcx , Bx :: Value > > {
330330 let mir = fx. mir ;
331331 let mut idx = 0 ;
332332 let mut llarg_idx = fx. fn_abi . ret . is_indirect ( ) as usize ;
333333
334- mir. args_iter ( ) . enumerate ( ) . map ( |( arg_index, local) | {
334+ let args = mir. args_iter ( ) . enumerate ( ) . map ( |( arg_index, local) | {
335335 let arg_decl = & mir. local_decls [ local] ;
336336
337337 if Some ( local) == mir. spread_arg {
@@ -427,7 +427,20 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
427427 bx. store_fn_arg ( arg, & mut llarg_idx, tmp) ;
428428 LocalRef :: Place ( tmp)
429429 }
430- } ) . collect ( )
430+ } ) . collect :: < Vec < _ > > ( ) ;
431+
432+ if fx. instance . def . requires_caller_location ( bx. tcx ( ) ) {
433+ assert_eq ! (
434+ fx. fn_abi. args. len( ) , args. len( ) + 1 ,
435+ "#[track_caller] fn's must have 1 more argument in their ABI than in their MIR" ,
436+ ) ;
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
431444}
432445
433446mod analyze;
0 commit comments