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

LLVM has a bug - PR32488 - 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 #40493.
Fixes #40573.
This commit is contained in:
Ariel Ben-Yehuda 2017-04-02 16:18:39 +03:00
parent ccce2c6eb9
commit 09ac56d6ef

View File

@ -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))
}