@@ -186,7 +186,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
186
186
187
187
// Allocate variable and temp allocas
188
188
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) ;
190
190
191
191
let mut allocate_local = |local| {
192
192
let decl = & mir. local_decls [ local] ;
@@ -328,14 +328,14 @@ fn create_funclets<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
328
328
/// indirect.
329
329
fn arg_local_refs < ' a , ' tcx , Bx : BuilderMethods < ' a , ' tcx > > (
330
330
bx : & mut Bx ,
331
- fx : & FunctionCx < ' a , ' tcx , Bx > ,
331
+ fx : & mut FunctionCx < ' a , ' tcx , Bx > ,
332
332
memory_locals : & BitSet < mir:: Local > ,
333
333
) -> Vec < LocalRef < ' tcx , Bx :: Value > > {
334
334
let mir = fx. mir ;
335
335
let mut idx = 0 ;
336
336
let mut llarg_idx = fx. fn_abi . ret . is_indirect ( ) as usize ;
337
337
338
- mir. args_iter ( ) . enumerate ( ) . map ( |( arg_index, local) | {
338
+ let args = mir. args_iter ( ) . enumerate ( ) . map ( |( arg_index, local) | {
339
339
let arg_decl = & mir. local_decls [ local] ;
340
340
341
341
if Some ( local) == mir. spread_arg {
@@ -431,7 +431,16 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
431
431
bx. store_fn_arg ( arg, & mut llarg_idx, tmp) ;
432
432
LocalRef :: Place ( tmp)
433
433
}
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
435
444
}
436
445
437
446
mod analyze;
0 commit comments