Skip to content

Commit 3fa9366

Browse files
authored
Merge pull request #916 from bjorn3/fn_once_for_box_without_alloca
Emulate `<Box<F> as FnOnce>::call_once` without `alloca`
2 parents 240d56c + c5b5b2b commit 3fa9366

6 files changed

+98
-351
lines changed

patches/0015-Remove-usage-of-unsized-locals.patch

-73
This file was deleted.

patches/0017-Fix-libtest-compilation.patch

-92
This file was deleted.

patches/0018-Add-FnBox-back.patch

-174
This file was deleted.

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2020-03-07
1+
nightly-2020-03-10

src/abi/mod.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ fn local_place<'tcx>(
288288
fx.local_map[&local]
289289
}
290290

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) {
292292
let ssa_analyzed = crate::analyze::analyze(fx);
293293

294294
#[cfg(debug_assertions)]
@@ -405,13 +405,17 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_block
405405
}
406406
}
407407

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);
411414

412-
let is_ssa = ssa_analyzed[local] == crate::analyze::SsaKind::Ssa;
415+
let is_ssa = ssa_analyzed[local] == crate::analyze::SsaKind::Ssa;
413416

414-
local_place(fx, local, layout, is_ssa);
417+
local_place(fx, local, layout, is_ssa);
418+
}
415419
}
416420

417421
fx.bcx

0 commit comments

Comments
 (0)