diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2020-09-18 18:46:56 -0300 |
|---|---|---|
| committer | Wesley Wiser <wwiser@gmail.com> | 2020-12-06 20:50:49 -0500 |
| commit | 318626710ee96b6ac2c59480bfc5f03048239220 (patch) | |
| tree | 684c7eeea8c270579d71671b90e82bc1321c7091 | |
| parent | 0f6f2d681b39c5f95459cd09cb936b6ceb27cd82 (diff) | |
| download | rust-318626710ee96b6ac2c59480bfc5f03048239220.tar.gz rust-318626710ee96b6ac2c59480bfc5f03048239220.zip | |
Do not make local copies of inline fns in debug mode
| -rw-r--r-- | compiler/rustc_middle/src/mir/mono.rs | 19 | ||||
| -rw-r--r-- | src/test/run-make-fulldeps/inline-always-many-cgu/Makefile | 7 |
2 files changed, 13 insertions, 13 deletions
diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs index 1e70f760504..b79c1a19a90 100644 --- a/compiler/rustc_middle/src/mir/mono.rs +++ b/compiler/rustc_middle/src/mir/mono.rs @@ -1,7 +1,6 @@ use crate::dep_graph::{DepConstructor, DepNode, WorkProduct, WorkProductId}; use crate::ich::{NodeIdHashingMode, StableHashingContext}; use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt}; -use rustc_attr::InlineAttr; use rustc_data_structures::base_n; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; @@ -103,17 +102,13 @@ impl<'tcx> MonoItem<'tcx> { // inlined function. If we're inlining into all CGUs then we'll // be creating a local copy per CGU. if generate_cgu_internal_copies { - return InstantiationMode::LocalCopy; - } - - // Finally, if this is `#[inline(always)]` we're sure to respect - // that with an inline copy per CGU, but otherwise we'll be - // creating one copy of this `#[inline]` function which may - // conflict with upstream crates as it could be an exported - // symbol. - match tcx.codegen_fn_attrs(instance.def_id()).inline { - InlineAttr::Always => InstantiationMode::LocalCopy, - _ => InstantiationMode::GloballyShared { may_conflict: true }, + InstantiationMode::LocalCopy + } else { + // Finally, if we've reached this point, then we should optimize for + // compilation speed. In that regard, we will ignore any `#[inline]` + // annotations on the function and simply codegen it as usual. This could + // conflict with upstream crates as it could be an exported symbol. + InstantiationMode::GloballyShared { may_conflict: true } } } MonoItem::Static(..) | MonoItem::GlobalAsm(..) => { 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; \ |
