Skip to content

Mir: remove Panic terminator and instead just call suitable lang item #29573

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

Closed
nikomatsakis opened this issue Nov 4, 2015 · 8 comments · Fixed by #30481
Closed

Mir: remove Panic terminator and instead just call suitable lang item #29573

nikomatsakis opened this issue Nov 4, 2015 · 8 comments · Fixed by #30481
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-needs-decision Issue: In need of a decision. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

Panic in MIR is unimplemented. It should call into the panic lang item.

@nikomatsakis nikomatsakis added E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html labels Nov 4, 2015
@wesleywiser
Copy link
Member

Hi, I'd like to give this a shot.

@nikomatsakis
Copy link
Contributor Author

@wesleywiser great! If you want to chat about it, the easiest way is to privmsg me on IRC (nmatsakis) or send me an email ([email protected]). I will note though that it may be that we should reshape panics to just be calls, in which case this task is more about handling calls than about panics per se, which is maybe a bigger job (but a very important one).

@nikomatsakis nikomatsakis changed the title Mir: Trans Panics Mir: remove Panic terminator and instead just call suitable lang item Nov 11, 2015
@nikomatsakis nikomatsakis added the I-needs-decision Issue: In need of a decision. label Nov 11, 2015
@nikomatsakis
Copy link
Contributor Author

I now think we should refactor panics to simply call into the appropriate lang item and not have an explicit Panic terminator.

@nagisa
Copy link
Member

nagisa commented Nov 13, 2015

Replacing Panic terminator with explicit call to language item that’s followed by a Diverge (I assume Diverge has the same semantics as intrinsics::unreachable) terminator sounds good to me.

@nagisa
Copy link
Member

nagisa commented Nov 13, 2015

On the other hand, it would make implementing certain codegen features such as -C no-landing-pads near-impossible? Then probably doesn’t sound as good as it did before 😃

@nikomatsakis
Copy link
Contributor Author

@nagisa I don't see why it makes that any harder. In such a mode we presumably would not emit a Panic either, and/or we'd change the lang item to abort (and strip away the landing pads path so that the call block has no successors).

@nikomatsakis
Copy link
Contributor Author

@nagisa also, the semantics of diverge are not unreachable. The diverge
terminator continues unwinding. Perhaps it should have been called "resume".

On Fri, Nov 13, 2015 at 3:00 PM, Simonas Kazlauskas <
[email protected]> wrote:

On the other hand, it would make implementing certain codegen features
such as -C no-landing-pads near-impossible? Then probably doesn’t sounds
as good as it did before 😃


Reply to this email directly or view it on GitHub
#29573 (comment).

@nikomatsakis
Copy link
Contributor Author

Though, we could say that if landing pads are disabled, then the Diverge
terminator just traps, and then we can keep directing all panic pathways
directly into the Diverge block. Not sure, plenty of ok options I guess.

On Fri, Nov 13, 2015 at 3:07 PM, Nicholas Matsakis [email protected]
wrote:

@nagisa also, the semantics of diverge are not unreachable. The diverge
terminator continues unwinding. Perhaps it should have been called "resume".

On Fri, Nov 13, 2015 at 3:00 PM, Simonas Kazlauskas <
[email protected]> wrote:

On the other hand, it would make implementing certain codegen features
such as -C no-landing-pads near-impossible? Then probably doesn’t sounds
as good as it did before 😃


Reply to this email directly or view it on GitHub
#29573 (comment).

bors added a commit that referenced this issue Jan 6, 2016
r? @nikomatsakis

This is a pretty big PR conflating changes to a few different block terminators (Call, DivergingCall, Panic, Resume, Diverge), because they are somewhat closely related.

Each commit has a pretty good description on what is being changed in each commit. The end result is greatly simplified CFG and translation for calls (no success branch if the function is diverging, no cleanup branch if there’s nothing to cleanup etc).

Fixes #30480
Fixes #29767
Partialy solves #29575
Fixes #29573
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 E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-needs-decision Issue: In need of a decision. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants