Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upMir: introduce overflow operations #29769
Comments
nikomatsakis
added
I-needs-decision
T-compiler
A-mir
labels
Nov 11, 2015
This comment has been minimized.
This comment has been minimized.
|
See also @eddyb's comment: #27840 (comment) |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
@Aatch Is this |
This comment has been minimized.
This comment has been minimized.
|
@Aatch You could generalize |
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
@Aatch I believe the cleanest solution would be to generalize |
This comment has been minimized.
This comment has been minimized.
|
This is closed by PR #33905, right? |
This comment has been minimized.
This comment has been minimized.
|
Indeed. Must've missed it when I made the PR. |
nikomatsakis commentedNov 11, 2015
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.