Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Do not make local copies of inline(always) fns in debug mode #76889

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions compiler/rustc_middle/src/mir/mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@ impl<'tcx> MonoItem<'tcx> {
}

// 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.
// that (unless in OptLevel::No) 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,
InlineAttr::Always if tcx.sess.opts.optimize != OptLevel::No => {
InstantiationMode::LocalCopy
}
_ => InstantiationMode::GloballyShared { may_conflict: true },
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/test/run-make-fulldeps/inline-always-many-cgu/Makefile
Original file line number Diff line number Diff line change
@@ -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; \
Expand Down