Do not make local copies of inline fns in debug mode
This commit is contained in:
parent
0f6f2d681b
commit
318626710e
2 changed files with 13 additions and 13 deletions
|
@ -1,7 +1,6 @@
|
||||||
use crate::dep_graph::{DepConstructor, DepNode, WorkProduct, WorkProductId};
|
use crate::dep_graph::{DepConstructor, DepNode, WorkProduct, WorkProductId};
|
||||||
use crate::ich::{NodeIdHashingMode, StableHashingContext};
|
use crate::ich::{NodeIdHashingMode, StableHashingContext};
|
||||||
use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt};
|
use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt};
|
||||||
use rustc_attr::InlineAttr;
|
|
||||||
use rustc_data_structures::base_n;
|
use rustc_data_structures::base_n;
|
||||||
use rustc_data_structures::fingerprint::Fingerprint;
|
use rustc_data_structures::fingerprint::Fingerprint;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
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
|
// inlined function. If we're inlining into all CGUs then we'll
|
||||||
// be creating a local copy per CGU.
|
// be creating a local copy per CGU.
|
||||||
if generate_cgu_internal_copies {
|
if generate_cgu_internal_copies {
|
||||||
return InstantiationMode::LocalCopy;
|
InstantiationMode::LocalCopy
|
||||||
}
|
} else {
|
||||||
|
// Finally, if we've reached this point, then we should optimize for
|
||||||
// Finally, if this is `#[inline(always)]` we're sure to respect
|
// compilation speed. In that regard, we will ignore any `#[inline]`
|
||||||
// that with an inline copy per CGU, but otherwise we'll be
|
// annotations on the function and simply codegen it as usual. This could
|
||||||
// creating one copy of this `#[inline]` function which may
|
// conflict with upstream crates as it could be an exported symbol.
|
||||||
// conflict with upstream crates as it could be an exported
|
InstantiationMode::GloballyShared { may_conflict: true }
|
||||||
// symbol.
|
|
||||||
match tcx.codegen_fn_attrs(instance.def_id()).inline {
|
|
||||||
InlineAttr::Always => InstantiationMode::LocalCopy,
|
|
||||||
_ => InstantiationMode::GloballyShared { may_conflict: true },
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MonoItem::Static(..) | MonoItem::GlobalAsm(..) => {
|
MonoItem::Static(..) | MonoItem::GlobalAsm(..) => {
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
all:
|
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 \
|
if cat $(TMPDIR)/*.ll | $(CGREP) -e '\bcall\b'; then \
|
||||||
echo "found call instruction when one wasn't expected"; \
|
echo "found call instruction when one wasn't expected"; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue