-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Mir: introduce overflow operations #29769
Comments
See also @eddyb's comment: #27840 (comment) |
I've just looked into doing this, and have something mostly working right now. The main problem is that the codegen is much worse than the current system due to the branches and checking being more explicit now. This means that the An idea I had to try to improve this is to allow larger temporaries to have their allocas omitted as well. Part of this requires having a way to get at the fields without using an lvalue, which I have done using a new |
@Aatch Is this |
@Aatch You could generalize |
@nikomatsakis yes. It actually looks to be working surprisingly well. It's effectively a short-hand for The codegen for overflow checking by the MIR is now basically the same as the codegen done by the current trans path, which was what my goal was. I'll have a PR ready soon I hope, so you can see what is going on. |
I experimented with supporting "SSA lvalues", and it gets complicated quick. However, I think we'll want it to improve codegen around function calls, which still require an on-stack location for the return. I think I'll try to tackle that first, since it's going to be a bigger project. |
Ok, so making the codegen better turns out to be surprisingly complicated. So I'm going to punt that to some future person. Instead I've focussed on getting the rest of the checks in. The checks for |
@Aatch I believe the cleanest solution would be to generalize |
This is closed by PR #33905, right? |
Indeed. Must've missed it when I made the PR. |
Currently the MIR doesn't handle overflow. My intended design was to add 'overflow operations' that yield a tuple (overflow-flag, result). This is roughly how LLVM does things. We would then check for overflow and panic if it occurs. @Aatch independently described this design as option 3.
The text was updated successfully, but these errors were encountered: