@@ -288,7 +288,7 @@ fn local_place<'tcx>(
288
288
fx. local_map [ & local]
289
289
}
290
290
291
- pub fn codegen_fn_prelude ( fx : & mut FunctionCx < ' _ , ' _ , impl Backend > , start_block : Block ) {
291
+ pub fn codegen_fn_prelude ( fx : & mut FunctionCx < ' _ , ' _ , impl Backend > , start_block : Block , should_codegen_locals : bool ) {
292
292
let ssa_analyzed = crate :: analyze:: analyze ( fx) ;
293
293
294
294
#[ cfg( debug_assertions) ]
@@ -405,13 +405,17 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_block
405
405
}
406
406
}
407
407
408
- for local in fx. mir . vars_and_temps_iter ( ) {
409
- let ty = fx. monomorphize ( & fx. mir . local_decls [ local] . ty ) ;
410
- let layout = fx. layout_of ( ty) ;
408
+ // HACK should_codegen_locals required for the ``implement `<Box<F> as FnOnce>::call_once`
409
+ // without `alloca``` hack in `base::trans_fn`.
410
+ if should_codegen_locals {
411
+ for local in fx. mir . vars_and_temps_iter ( ) {
412
+ let ty = fx. monomorphize ( & fx. mir . local_decls [ local] . ty ) ;
413
+ let layout = fx. layout_of ( ty) ;
411
414
412
- let is_ssa = ssa_analyzed[ local] == crate :: analyze:: SsaKind :: Ssa ;
415
+ let is_ssa = ssa_analyzed[ local] == crate :: analyze:: SsaKind :: Ssa ;
413
416
414
- local_place ( fx, local, layout, is_ssa) ;
417
+ local_place ( fx, local, layout, is_ssa) ;
418
+ }
415
419
}
416
420
417
421
fx. bcx
0 commit comments