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

Revise semantics and implementation of #[rustc_inherit_overflow_checks]. #35310

Closed
eddyb opened this issue Aug 4, 2016 · 1 comment · Fixed by #107921
Closed

Revise semantics and implementation of #[rustc_inherit_overflow_checks]. #35310

eddyb opened this issue Aug 4, 2016 · 1 comment · Fixed by #107921
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@eddyb
Copy link
Member

eddyb commented Aug 4, 2016

As of #35300, two places in MIR trans look for overflowing operations used when overflow checks are off.
Such operations are then assumed not to overflow, effectively changing semantics on-the-fly.

This is done so that the functions marked #[rustc_inherit_overflow_checks] in libcore can be used cross-crate (e.g. generics over arithmetic traits like Add) and use the overflow checks only when enabled.

A better approach would be to run a pass on the inlined MIR itself to remove these operations.
This would let alternative backends get away without reproducing all of the logic to elide overflow checks.

There's also the possibility of distributing multiple libstd versions, one with overflow checks enabled, and one without, or build such versions on demand, but that is longer-term (cc @rust-lang/infra).

cc @rust-lang/compiler

@eddyb eddyb added C-cleanup Category: PRs that clean code up or issues documenting cleanup. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html labels Aug 4, 2016
@steveklabnik
Copy link
Member

Triage: I'm not aware of any changes here.

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 C-cleanup Category: PRs that clean code up or issues documenting cleanup. 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