From 0d52c562db18e85cf53078c9ddb40abe469a4aab Mon Sep 17 00:00:00 2001
From: Gregor Peach <gregorpeach@gmail.com>
Date: Sat, 4 Jan 2020 15:40:36 -0800
Subject: [PATCH] Change opt-level from 2 back to 3

In Cargo.toml, the opt-level for `release` and `bench` was
overridden to be 2. This was to work around a problem with LLVM
7. However, rust no longer uses LLVM 7, so this is no longer
needed.

This creates a small compile time regression in MIR constant eval,
so I've added a #[inline(always)] on the `step` function used in
const eval

Also creates a binary size increase in wasm-stringify-ints-small,
so I've bumped the limit there.
---
 Cargo.toml                                           | 7 -------
 src/librustc_mir/interpret/step.rs                   | 3 +++
 src/test/run-make/wasm-stringify-ints-small/Makefile | 2 +-
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index a242f090fbc..8c3c858de1d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -30,13 +30,6 @@ exclude = [
   "obj",
 ]
 
-# Curiously, LLVM 7.0 will segfault if compiled with opt-level=3
-# See issue https://github.com/rust-lang/rust/issues/52378
-[profile.release]
-opt-level = 2
-[profile.bench]
-opt-level = 2
-
 # These options are controlled from our rustc wrapper script, so turn them off
 # here and have them controlled elsewhere.
 [profile.dev]
diff --git a/src/librustc_mir/interpret/step.rs b/src/librustc_mir/interpret/step.rs
index a99abc4cbf4..7d59c0181a8 100644
--- a/src/librustc_mir/interpret/step.rs
+++ b/src/librustc_mir/interpret/step.rs
@@ -38,6 +38,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
     /// Returns `true` as long as there are more things to do.
     ///
     /// This is used by [priroda](https://github.com/oli-obk/priroda)
+    ///
+    /// This is marked `#inline(always)` to work around adverserial codegen when `opt-level = 3`
+    #[inline(always)]
     pub fn step(&mut self) -> InterpResult<'tcx, bool> {
         if self.stack.is_empty() {
             return Ok(false);
diff --git a/src/test/run-make/wasm-stringify-ints-small/Makefile b/src/test/run-make/wasm-stringify-ints-small/Makefile
index 26de6a0c689..01e1c6b0ce8 100644
--- a/src/test/run-make/wasm-stringify-ints-small/Makefile
+++ b/src/test/run-make/wasm-stringify-ints-small/Makefile
@@ -4,7 +4,7 @@ ifeq ($(TARGET),wasm32-unknown-unknown)
 all:
 	$(RUSTC) foo.rs -C lto -O --target wasm32-unknown-unknown
 	wc -c < $(TMPDIR)/foo.wasm
-	[ "`wc -c < $(TMPDIR)/foo.wasm`" -lt "20500" ]
+	[ "`wc -c < $(TMPDIR)/foo.wasm`" -lt "25000" ]
 else
 all:
 endif