Skip to content

Commit

Permalink
Rollup merge of rust-lang#41015 - arielb1:new-block-stack, r=alexcric…
Browse files Browse the repository at this point in the history
…hton

mark build::cfg::start_new_block as inline(never)

LLVM has a bug - [PR32488](https://bugs.llvm.org//show_bug.cgi?id=32488) - where it fails to deduplicate allocas in some
circumstances. The function `start_new_block` has allocas totalling 1216
bytes, and when LLVM inlines several copies of that function into
the recursive function `expr::into`, that function's stack space usage
goes into tens of kiBs, causing stack overflows.

Mark `start_new_block` as inline(never) to keep it from being inlined,
getting stack usage under control.

Fixes rust-lang#40493.
Fixes rust-lang#40573.

r? @eddyb
  • Loading branch information
Ariel Ben-Yehuda authored Apr 5, 2017
2 parents 9d07447 + 09ac56d commit b712950
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/librustc_mir/build/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ impl<'tcx> CFG<'tcx> {
&mut self.basic_blocks[blk]
}

// llvm.org/PR32488 makes this function use an excess of stack space. Mark
// it as #[inline(never)] to keep rustc's stack use in check.
#[inline(never)]
pub fn start_new_block(&mut self) -> BasicBlock {
self.basic_blocks.push(BasicBlockData::new(None))
}
Expand Down

0 comments on commit b712950

Please sign in to comment.