about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>2017-04-05 23:01:09 +0000
committerGitHub <noreply@github.com>2017-04-05 23:01:09 +0000
commitb712950d7b3a91e78d195adff49afb4a27abeb8d (patch)
tree02770b3b6645580c61106ef78c3b13e67159679c
parent9d074473da5fef4b1d9ebbbb7f181edcb7a365a0 (diff)
parent09ac56d6efd41c02cbb7f8714d59bdd43f663ec8 (diff)
downloadrust-b712950d7b3a91e78d195adff49afb4a27abeb8d.tar.gz
rust-b712950d7b3a91e78d195adff49afb4a27abeb8d.zip
Rollup merge of #41015 - arielb1:new-block-stack, r=alexcrichton
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 #40493.
Fixes #40573.

r? @eddyb
-rw-r--r--src/librustc_mir/build/cfg.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/librustc_mir/build/cfg.rs b/src/librustc_mir/build/cfg.rs
index 71e97e4bfe0..c503b8c7fe0 100644
--- a/src/librustc_mir/build/cfg.rs
+++ b/src/librustc_mir/build/cfg.rs
@@ -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))
     }