Uh oh!
There was an error while loading. Please reload this page.
Add MIR Validate statement - #43403
Conversation
rust-highfive
commented
Jul 22, 2017
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
oli-obk
commented
Jul 22, 2017
Tidy fails due to lines longer than 100 chars |
RalfJung
commented
Jul 22, 2017
Yeah I find it very hard to follow that requirement. Always feel like I have to make my code ugly to comply. Seems like I missed some places. :/ |
nikomatsakis
commented
Jul 25, 2017
Ideally I'd like to run AddValidation before ElaborateDrops and after EraseRegions. For this to work, I need to move ElaborateDrops up, but RalfJung@3eb4141 fails badly -- many tests now report "Broken MIR: moving out of lvalue". @arielb1 I suppose just naively moving the pass around doesn't work.^^ Anything else I should try? EDIT: Also I wasn't sure about the comments saying what cannot be done starting where. Those are probably wrong in my patch. |
RalfJung
commented
Jul 27, 2017
With some more help from @arielb1 I managed to reorder the passes without breaking everything (well, the test suite still passes). They also advised me to change |
RalfJung
commented
Jul 27, 2017
This relies on #43512, which however is already r+'ed so it should land soon-ish. |
5a26f2c to
95105afComparebors
commented
Jul 28, 2017
☔ The latest upstream changes (presumably #43324) made this pull request unmergeable. Please resolve the merge conflicts. |
RalfJung
commented
Jul 28, 2017
I rebased to resolve the merge conflict. |
…ribe when we can rely on them being locked in memory
This matters if the lvalues that is suspended involves Deref'ing a reference -- that reference's lifetime will then not be in the type any more
… different Lvalue type
RalfJung
commented
Aug 1, 2017
Still failing to build libstd with the flag turned on: I am at loss here. Struct ctors are functions that have their own MIR...? |
arielb1
commented
Aug 1, 2017
Yes they are. The MIR is created by https://github.com/rust-lang/rust/blob/master/src/librustc_mir/shim.rs |
RalfJung
commented
Aug 1, 2017
I see. I fixed the code to handle that, but now I get I suppose defaulted trait methods are yet another category that needs separate handling. |
RalfJung
commented
Aug 1, 2017
Okay, now I am seeing really strange behavior... I thought by returning I also just realized that closures in an unsafe fn probably can use unsafe features as well, so I will have to extend my scan into the closure environment accordingly. |
RalfJung
commented
Aug 1, 2017
Okay, it seems to all work now. This is ready to be merged from my side. I hope I got all this HIR code right. I would really like to test whether closures are correctly detected to be unsafe, but unfortunately, mir-opt tests are not suited for this: Closures contain the filename in their type and name, which shows up in the lines we would like to test for. |
RalfJung
commented
Aug 2, 2017
Ah dang it, I got another ICE in miri's test suite... |
RalfJung
commented
Aug 2, 2017
Fixed that as well (thanks @eddyb) |
RalfJung
commented
Aug 2, 2017
Thanks :) So, what has to happen now to get r+? |
nikomatsakis
commented
Aug 4, 2017
@bors r+ |
bors
commented
Aug 4, 2017
📌 Commit 7d8dc7a has been approved by |
bors
commented
Aug 4, 2017
Add MIR Validate statement This adds statements to MIR that express when types are to be validated (following [Types as Contracts](https://internals.rust-lang.org/t/types-as-contracts/5562)). Obviously nothing is stabilized, and in fact a `-Z` flag has to be passed for behavior to even change at all. This is meant to make experimentation with Types as Contracts in miri possible. The design is definitely not final. Cc @nikomatsakis@aturon
bors
commented
Aug 4, 2017
☀️ Test successful - status-appveyor, status-travis |
alexcrichton
commented
Aug 12, 2017
It looks like this PR regressed a number of benchmarks 5-7% on perf.rust-lang.org, @RalfJung do you know if this could perhaps cause a performance impact when not enabled? |
alexcrichton
commented
Aug 12, 2017
A more clear way to see this regression is perhaps here |
RalfJung
commented
Aug 12, 2017
Is this compile tune or run time? I guess compile time, but it's not entirely clear to me. That is strange, the new pass does nothing when not enabled. There is a slight chance that more @arielb1 could reordering the passes have a bad effect on performance? |
@RalfJung Compile time. In particular it seems to be the LLVM pass that takes longer time. Trans time is also increasing but the contribution to increased total time is small. |
alexcrichton
commented
Aug 12, 2017
Ok I'll open a dedicated issue for this in that case! |
This adds statements to MIR that express when types are to be validated (following Types as Contracts). Obviously nothing is stabilized, and in fact a
-Zflag has to be passed for behavior to even change at all.This is meant to make experimentation with Types as Contracts in miri possible. The design is definitely not final.
Cc @nikomatsakis@aturon