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

Mark inactive enum variants along "otherwise" edge as uninitialized #77377

Conversation

ecstatic-morse
Copy link
Contributor

@ecstatic-morse ecstatic-morse commented Sep 30, 2020

This is a slight improvement on #68528 and #73879. Previously, the interface to the dataflow framework did not allow edge-specific effects along the "otherwise" edge of a SwitchInt terminator. #77242 fixed this. Now we can mark enum variants whose discriminant is handled in an integer-valued SwitchInt edge as definitely uninitialized along the "otherwise" edge. Notably, this applies within an else block attached to an if let expression.

@ecstatic-morse
Copy link
Contributor Author

@bors try
@rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Sep 30, 2020

⌛ Trying commit e0438129233fbe7e1724b05c52f46bd2f2b89730 with merge d23533d70fe2773aabe056564e0930e7e72b70be...

@bors
Copy link
Contributor

bors commented Sep 30, 2020

☀️ Try build successful - checks-actions, checks-azure
Build commit: d23533d70fe2773aabe056564e0930e7e72b70be (d23533d70fe2773aabe056564e0930e7e72b70be)

@rust-timer
Copy link
Collaborator

Queued d23533d70fe2773aabe056564e0930e7e72b70be with parent 867bd42, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (d23533d70fe2773aabe056564e0930e7e72b70be): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never

@ecstatic-morse ecstatic-morse added the S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. label Oct 1, 2020
@ecstatic-morse
Copy link
Contributor Author

ecstatic-morse commented Oct 1, 2020

With two exceptions, this is a small win across the board, especially for wall times. However, I'm going to mark this as blocked until #77382 and #74551 are resolved.

This means all enum variants whose discriminant has a dedicated outgoing
edge in the `SwitchInt` terminator.
@ecstatic-morse
Copy link
Contributor Author

ecstatic-morse commented Oct 3, 2020

Thanks to cuviper, we've learned that this class of optimizations is not the root cause of #77382. In a Bayesian sense, I'm now more confident that #74551 is similarly unrelated, although I still don't have the hardware to verify that hypothesis. Given the new data, I'm comfortable getting this on nightly and riding the trains to stable. Most users (including people building rustc) will see a small compile-time speed-up.

@ecstatic-morse ecstatic-morse added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Oct 3, 2020
@ecstatic-morse
Copy link
Contributor Author

r? @pnkfelix
cc @oli-obk

@ecstatic-morse ecstatic-morse marked this pull request as ready for review October 3, 2020 23:39
@bors
Copy link
Contributor

bors commented Oct 5, 2020

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

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@camelid camelid added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 23, 2020
@Dylan-DPC-zz
Copy link

@pnkfelix any updates on the review?

} else {
// We're on the otherwise branch. All variants that we visited above are known to be
// uninitialized.
for &variant_mpi in &variant_mpis_with_edge {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a guarantee that the otherwise branch is always invoked last during the iteration performed by edge_effects.apply?

Because, as best as I can tell, it seems like you are relying here on such a guarantee (since you are accumulating all the values in variant_mpis_with_edge during the callback invocations on the non-otherwise edges.

But skimming over the doc comments added in PR #77242, I do not see any such guarantee in the documentation for apply_switch_int_edge_effects.

(And overall, I think the logic here would be easier to understand if the block structure in the code reflected that ordering constraint, even if it requires changes to the dataflow API. I don't know the best way to express it; perhaps by two distinct callbacks instead of just one, where the first callback is invoked for all the edge.value.is_some() cases here, and the second callback for the otherwise case?)

@pnkfelix
Copy link
Member

This is a really cool idea.

I will admit I am concerned about whether the code is relying on undocumented guarantees, as noted in a comment on the diff itself.

But that's the main piece of feedback I have at the moment.

@pnkfelix pnkfelix 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 Oct 29, 2020
@Dylan-DPC-zz
Copy link

@ecstatic-morse any updates?

@camelid camelid added A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html A-mir-opt Area: MIR optimizations labels Dec 4, 2020
@camelid camelid 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 4, 2020
@JohnCSimon JohnCSimon 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 11, 2021
@JohnCSimon JohnCSimon 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 1, 2021
@Dylan-DPC-zz
Copy link

Closing this as inactive

@Dylan-DPC-zz Dylan-DPC-zz added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html A-mir-opt Area: MIR optimizations S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants