Uh oh!
There was an error while loading. Please reload this page.
miri: improve and simplify overflow detection - #69002
Conversation
| Rem => { | ||
| if r == -1 && l == (1 << (size.bits() - 1)) { | ||
| return Ok((Scalar::from_uint(l, size), true, left_layout.ty)); | ||
| return Ok((Scalar::from_int(0, size), true, left_layout.ty)); |
There was a problem hiding this comment.
I think what this used to do for Rem is plain wrong -- it returned the wrong result. However, even in release builds, remainder is checked for overflow. So, during normal execution in CTFE/Miri, the overflowing case here is unreachable. It is reachable in const-prop, which however does not care about the return value, just about whether there is an overflow.
There was a problem hiding this comment.
With control flow const prop we could stop propping in arms that are only reachable by a failing assert terminator.
There was a problem hiding this comment.
We could also declare int_min / -1 and int_min % -1 to be UB. This is consistent with MIR building always checking that, and it should resolve the rem/div part of #69020.
There was a problem hiding this comment.
Though OTOH, it is probably more consistent to handle all overflow the same way... so maybe not. I hope to play with this next weekend.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Let's do a perf run just to be sure there's no regressions and then we can land this. @bors try @rust-timer queue |
rust-timer
commented
Feb 10, 2020
Awaiting bors try build completion |
bors
commented
Feb 10, 2020
⌛ Trying commit d6c5a04 with merge 5bf0888774eedd0302d15303b594839d4c70873e... |
rust-timer
commented
Feb 10, 2020
Awaiting bors try build completion |
bors
commented
Feb 10, 2020
⌛ Trying commit d6c5a04 with merge 0f7a6fbaf793dfb724765f4d67fe0fa0addb53fb... |
bors
commented
Feb 10, 2020
☀️ Try build successful - checks-azure |
wesleywiser
commented
Feb 11, 2020
@rust-timer build 0f7a6fbaf793dfb724765f4d67fe0fa0addb53fb |
rust-timer
commented
Feb 11, 2020
Queued 0f7a6fbaf793dfb724765f4d67fe0fa0addb53fb with parent 4d1241f, future comparison URL. |
RalfJung
commented
Feb 11, 2020
Looks like the auto-queueing thing doesn't work any more? |
wesleywiser
commented
Feb 11, 2020
It's been buggy lately but I think it got confused when I edited my comment. Perf looks unaffected. @bors r=oli-obk,wesleywiser |
bors
commented
Feb 11, 2020
📌 Commit c561d23 has been approved by |
RalfJung
commented
Feb 11, 2020
Is there a bug report for this? I can't find any at https://github.com/rust-lang-nursery/rustc-perf/issues |
…k,wesleywiser miri: improve and simplify overflow detection This simplifies the overflow detection for signed binary operators, and adds overflow detection to unary operators so that const-prop doesn't have to crudely hand-roll that. It also fixes some bugs in the operator implementation that however, I think, were not observable. r? @oli-obk@wesleywiser
Rollup of 7 pull requests Successful merges: - #67954 (Support new LLVM pass manager) - #68981 ( Account for type params on method without parentheses) - #69002 (miri: improve and simplify overflow detection) - #69038 (Add initial debug fmt for Backtrace) - #69040 (Cleanup SGX entry code) - #69086 (Update compiler-builtins to 0.1.25) - #69095 (Minified theme check) Failed merges: r? @ghost
miri: fix exact_div Turns out `exact_div` was relying on the broken behavior of `Rem` for `int_min % -1` that was fixed in rust-lang#69002. This PR fixes `exact_div`. Inside rustc, `exact_div` is only used in a single place where the divisor is always positive (in `ptr_offset_from`), so we cannot test the fix in rustc. The Miri test suite covers this through the `exact_div` intrinsic, though (and it is how I found out). One step to rust-lang#69117 (then we also need to address build failures introduced by rust-lang#68969) r? @oli-obk
This simplifies the overflow detection for signed binary operators, and adds overflow detection to unary operators so that const-prop doesn't have to crudely hand-roll that.
It also fixes some bugs in the operator implementation that however, I think, were not observable.
r? @oli-obk@wesleywiser