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

Crate metadata nondefid args #41780

Closed

Conversation

cramertj
Copy link
Member

@cramertj cramertj commented May 6, 2017

Builds on #41766
cc #41417

I started working on queryifying the crate metadata functions that take CrateNum as an argument. However, a lot of these showed up in trans, which doesn't currently have access to tcx. I plumbed it through, but after doing so I'm not sure how to set it up in driver, which makes me think this wasn't the right thing to do 😆 I'm imagining there's a reason that trans relies upon Session instead of TyCtxt. If that's the case, how should I proceed?

r? @nikomatsakis

@nikomatsakis
Copy link
Contributor

@cramertj

a lot of these showed up in trans, which doesn't currently have access to tcx

wait, what? Trans definitely has access to a tcx.

@nikomatsakis
Copy link
Contributor

@cramertj can you give a more specific pointer to the part of trans you meant?

@cramertj
Copy link
Member Author

cramertj commented May 6, 2017

@nikomatsakis Yeah, that's what I would've expected haha. But
here, here, here, and here it looks like I only had access to &Session, when I needed TyCtxt. I'm clearly misunderstanding something here.

@Mark-Simulacrum Mark-Simulacrum added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 7, 2017
@cramertj
Copy link
Member Author

cramertj commented May 8, 2017

@nikomatsakis and I just discussed this on IRC. In the LLVM passes there's no tcx right now. This is intentional, as some of the tcx arenas are dropped before the LLVM phase to limit peak memory usage. For now, I'm going to change this PR to leave those methods as-is, tag with a FIXME, and open an issue tracking this problem.

@bors
Copy link
Contributor

bors commented May 9, 2017

☔ The latest upstream changes (presumably #41709) made this pull request unmergeable. Please resolve the merge conflicts.

@@ -804,6 +845,10 @@ fn metadata_dep_node(def_id: DefId) -> DepNode<DefId> {
DepNode::MetaData(def_id)
}

fn cratenum_metadata_dep_node(crate_num: CrateNum) -> DepNode<DefId> {
DepNode::MetaDataByCrateNum(crate_num)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just use MetaDataByCrateNum above, the functions are used when the variants don't match the key exactly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should have DepNode with a cratenum in it, though, at least not yet, as it won't get remapped properly when being loaded back up.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikomatsakis what would you suggest instead?

@@ -786,6 +818,15 @@ define_maps! { <'tcx>
[] item_body_nested_bodies: metadata_dep_node(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
[] const_is_rvalue_promotable_to_static: metadata_dep_node(DefId) -> bool,
[] is_mir_available: metadata_dep_node(DefId) -> bool,

[] is_const_fn: metadata_dep_node(DefId) -> bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's something in MIR const qualif doing this check, so that could be fully replaced by this (right now users of this query have to take into account the fact that it only works cross-crate).

@eddyb
Copy link
Member

eddyb commented May 10, 2017

@cramertj I think the thing to do here is to query the information ahead of time and maybe even not have &Session around - that is, post-translation the backend should be as detached as possible from rustc.

@cramertj
Copy link
Member Author

@eddyb What's the right way to do that so as not to mess up dependency tracking? Or do we even care about dependencies post-translation?

@eddyb
Copy link
Member

eddyb commented May 11, 2017

@cramertj Post-translation should be fully deterministic in terms of dependencies.
Treat is as "creating a build plan" that post-translation obeys. Unless you want to hash its results, it's fine.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 14, 2017
@alexcrichton
Copy link
Member

ping @cramertj just wanted to keep this on your radar, do you think you'll have a chance to rebase?

@cramertj
Copy link
Member Author

@alexcrichton This is based on top of another PR of mine that requires a test on Windows, and I haven't been able to get LLVM to build properly on my Windows machine. I'll close this for now and open a new PR when I have that sorted out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants