-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Translate shims using MIR #39628
Translate shims using MIR #39628
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
☔ The latest upstream changes (presumably #39586) made this pull request unmergeable. Please resolve the merge conflicts. |
Hi @arielb1, |
Some functions in Rust, such as enum variant constructions (e.g. |
cc @rust-lang/compiler |
@arielb1 to what end? what you're doing and why you're doing it are equally important. Your commit messages don't provide information on your rationale 🙁 |
@mrhota less special-casing and less convoluted code in the compiler |
It also pulls trans-specific code out into MIR in a way that will work for alternative backends (e.g. miri, mir2wasm), reducing duplication between them. |
src/librustc/ty/instance.rs
Outdated
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] | ||
pub enum InstanceDef<'tcx> { | ||
Item(DefId), | ||
// <fn() as FnTrait>::call_* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more explicit comment would be nice -- It's not clear to me what the Ty<'tcx>
represents here.
☔ The latest upstream changes (presumably #40091) made this pull request unmergeable. Please resolve the merge conflicts. |
f52b583
to
6f607d6
Compare
Deep | ||
} | ||
|
||
pub trait DropElaborator<'a, 'tcx: 'a> : fmt::Debug { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this file not in librustc_mir/transform
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's not a MIR pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM so far! r=me with those extra FIXMEs if you want to land it like this
src/librustc/ty/context.rs
Outdated
pub shim_mir_cache: RefCell<FxHashMap<ty::InstanceDef<'tcx>, | ||
&'tcx RefCell<Mir<'tcx>>>>, | ||
pub mir_shimmer: RefCell<Option<Box<ty::MirShimmer<'tcx>>>>, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put a FIXME
on these to eventually integrate them better with the rest of on-demand?
@@ -2302,6 +2312,22 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { | |||
queries::mir::get(self, DUMMY_SP, did).borrow() | |||
} | |||
|
|||
/// Return the possibly-auto-generated MIR of a (DefId, Subst) pair. | |||
pub fn instance_mir(self, instance: ty::InstanceDef<'gcx>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same FIXME
here, I suppose.
src/librustc/ty/context.rs
Outdated
@@ -423,6 +423,8 @@ pub struct GlobalCtxt<'tcx> { | |||
pub hir: hir_map::Map<'tcx>, | |||
pub maps: maps::Maps<'tcx>, | |||
|
|||
// This is not a ty::maps cache because it contains Tys, instead | |||
// it is structured similarly to selection_cache. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if you have a dep_node
method, you can use it to move this to on-demand.
7d069ec
to
bd92573
Compare
☔ The latest upstream changes (presumably #39648) made this pull request unmergeable. Please resolve the merge conflicts. |
Now ready (except for cleanup, and I prefer to land it now given that this PR is rather big enough already). r? @eddyb |
040f333
to
9f5def1
Compare
I can't see the end of that appveyor log. |
sccache failure @bors retry |
⌛ Testing commit 5dc8548 with merge 35617fc... |
💔 Test failed - status-appveyor |
⌛ Testing commit 5dc8548 with merge 0b1ddef... |
Mac builders offline @bors retry |
⌛ Testing commit 5dc8548 with merge 5e30f81... |
💔 Test failed - status-travis |
Translate shims using MIR This removes one large remaining part of old trans.
Mac test timeout? @bors retry |
☀️ Test successful - status-appveyor, status-travis |
This removes one large remaining part of old trans.