about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-01-08 15:21:45 +0000
committerbors <bors@rust-lang.org>2021-01-08 15:21:45 +0000
commitddf2cc7f8eb34f1a63b491d6a52e3e8208393c09 (patch)
treef449c4ae5cbf5116b86f6755d8df7a7c35628498 /src
parent937f629535f38c655267f1ed21ce6830f592f5df (diff)
parent07a59822aacaf53ef2396b6e43fa3e8ad3a3e983 (diff)
downloadrust-ddf2cc7f8eb34f1a63b491d6a52e3e8208393c09.tar.gz
rust-ddf2cc7f8eb34f1a63b491d6a52e3e8208393c09.zip
Auto merge of #76896 - spastorino:codegen-inline-fns2, r=davidtwco,wesleywiser
Do not make local copies of inline fns in debug mode

r? `@wesleywiser`

cc `@rust-lang/wg-incr-comp`

If this is correct it supersedes https://github.com/rust-lang/rust/pull/76889

Related to #54089
Diffstat (limited to 'src')
-rw-r--r--src/test/incremental/hygiene/load_cached_hygiene.rs9
-rw-r--r--src/test/incremental/remapped_paths_cc/main.rs9
-rw-r--r--src/test/run-make-fulldeps/inline-always-many-cgu/Makefile7
3 files changed, 21 insertions, 4 deletions
diff --git a/src/test/incremental/hygiene/load_cached_hygiene.rs b/src/test/incremental/hygiene/load_cached_hygiene.rs
index 8124141418b..d6a5cb993a4 100644
--- a/src/test/incremental/hygiene/load_cached_hygiene.rs
+++ b/src/test/incremental/hygiene/load_cached_hygiene.rs
@@ -1,5 +1,5 @@
 // revisions:rpass1 rpass2
-// compile-flags: -Z query-dep-graph
+// compile-flags: -Z query-dep-graph -O
 // aux-build:cached_hygiene.rs
 
 // This tests the folllowing scenario
@@ -19,7 +19,12 @@
 // the metadata. Specifically, we were not resetting `orig_id`
 // for an `EpxnData` generate in the current crate, which would cause
 // us to serialize the `ExpnId` pointing to a garbage location in
-// the metadata.
+// the metadata.o
+
+// NOTE: We're explicitly passing the `-O` optimization flag because if optimizations are not
+// enabled, then rustc will ignore the `#[inline(always)]` attribute which means we do not load
+// the optimized mir for the unmodified function to be loaded and so the CGU containing that
+// function will be reused.
 
 #![feature(rustc_attrs)]
 
diff --git a/src/test/incremental/remapped_paths_cc/main.rs b/src/test/incremental/remapped_paths_cc/main.rs
index b01f02444ea..735635029da 100644
--- a/src/test/incremental/remapped_paths_cc/main.rs
+++ b/src/test/incremental/remapped_paths_cc/main.rs
@@ -1,11 +1,18 @@
 // revisions:rpass1 rpass2 rpass3
-// compile-flags: -Z query-dep-graph -g
+// compile-flags: -Z query-dep-graph -g -O
 // aux-build:extern_crate.rs
 
 // ignore-asmjs wasm2js does not support source maps yet
+
 // This test case makes sure that we detect if paths emitted into debuginfo
 // are changed, even when the change happens in an external crate.
 
+// NOTE: We're explicitly passing the `-O` optimization flag because if no optimizations are
+// requested, rustc will ignore the `#[inline]` attribute. This is a performance optimization for
+// non-optimized builds which causes us to generate fewer copies of inlined functions when
+// runtime performance doesn't matter. Without this flag, the function will go into a different
+// CGU which can be reused by this crate.
+
 #![feature(rustc_attrs)]
 
 #![rustc_partition_reused(module="main", cfg="rpass2")]
diff --git a/src/test/run-make-fulldeps/inline-always-many-cgu/Makefile b/src/test/run-make-fulldeps/inline-always-many-cgu/Makefile
index 0cab955f644..d12a23fbbf0 100644
--- a/src/test/run-make-fulldeps/inline-always-many-cgu/Makefile
+++ b/src/test/run-make-fulldeps/inline-always-many-cgu/Makefile
@@ -1,7 +1,12 @@
 -include ../tools.mk
 
 all:
-	$(RUSTC) foo.rs --emit llvm-ir -C codegen-units=2
+	$(RUSTC) foo.rs --emit llvm-ir -C codegen-units=2 -C opt-level=0
+	if ![cat $(TMPDIR)/*.ll | $(CGREP) -e '\bcall\b']; then \
+		echo "not found call instruction when one was expected"; \
+		exit 1; \
+	fi
+	$(RUSTC) foo.rs --emit llvm-ir -C codegen-units=2 -C opt-level=1
 	if cat $(TMPDIR)/*.ll | $(CGREP) -e '\bcall\b'; then \
 		echo "found call instruction when one wasn't expected"; \
 		exit 1; \