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 up[MIR] non-zeroing drop #33622
Conversation
rust-highfive
assigned
nrc
May 13, 2016
This comment has been minimized.
This comment has been minimized.
|
r? @nrc (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
rust-highfive
assigned
nikomatsakis
and unassigned
nrc
May 13, 2016
This comment has been minimized.
This comment has been minimized.
|
After this MIR pass, will all MIR drops be unconditional? (That is, any conditional drops will be guarded by explicit conditional branching in the MIR.) |
This comment has been minimized.
This comment has been minimized.
|
Right. |
arielb1
changed the title
[WIP] [MIR] Non-zeroing drop
[MIR] non-zeroing drop
May 14, 2016
This comment has been minimized.
This comment has been minimized.
|
Passes |
This comment has been minimized.
This comment has been minimized.
|
cc #5016 This is awesome! Do we have benchmarks? Will functions like |
This comment has been minimized.
This comment has been minimized.
|
Performance numbers: stage1 MIR librustc (old):
stage2 MIR librustc:
|
This comment has been minimized.
This comment has been minimized.
|
stage 3 MIR librustc (there was some perf issue with stage2 apparently).
Non
|
This comment has been minimized.
This comment has been minimized.
|
|
arielb1
force-pushed the
arielb1:elaborate-drops
branch
from
b3e4b52
to
470ffbf
May 14, 2016
This comment has been minimized.
This comment has been minimized.
|
perf after rebase:
I get the feeling that SimpifyCfg is not doing its work. |
This comment has been minimized.
This comment has been minimized.
|
@arielb1 What makes you think that? IOW, what do you expect it to do that doesn't happen? |
This comment has been minimized.
This comment has been minimized.
|
Just that there are no perf improvements over its merge. Maybe LLVM just does this by itself. |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis @arielb1 I was under the impression that I would be given a chance to put up a properly revised PR of the data flow fixes (cleaning up the warnings and the commit history). I obviously can't stop people from merging this PR as is, but it would be a little irritating to me if that happened |
This comment has been minimized.
This comment has been minimized.
|
(In any case, I'll try to soon put up a separate PR with just the data flow fixes, that will include the relevant changes contributed by @arielb1 from this PR, and link to this PR when i do. hopefully that will happen in the next eight hours. I recommend waiting until that happens before initiating formal code review, at least if you plan to go commit by commit) |
This comment has been minimized.
This comment has been minimized.
|
I just wanted to open my code for review. Will rebase on top of yours. |
This comment has been minimized.
This comment has been minimized.
|
@arielb1 Yeah, LLVM does this just fine, the point of having it as a MIR pass is that we a) generate a little less bad code for the unoptimized case, and b) can possibly do more optimizations that are local to a single basic block instead of having to look across block boundaries. |
dotdash
reviewed
May 16, 2016
| /// Drop the Lvalue and write an operand over it | ||
| DropAndReplace { | ||
| location: Lvalue<'tcx>, | ||
| value: Operand<'tcx>, |
This comment has been minimized.
This comment has been minimized.
dotdash
May 16, 2016
Contributor
For consistency, using value and replacement might be a better idea here. Having value mean different things for Drop and DropAndReplace seems confusing.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
c) humans can actually read the generated MIR. That's 3 good reasons. I might just add a span for temporaries. For debugging and readability, you know. |
This comment has been minimized.
This comment has been minimized.
|
okay, thanks. (Sorry for any cranky old man attitude in my response; it was 5 in the morning and I (unlike niko) don't operate well at that hour at this point in my life.) I have posted the dataflow fixes PR at #33667 ; I tried to extract the relevant portions of the things you fixes in the dataflow into that PR, while leaving out the stuff that was solely for your non-zeroing drop work. So while it probably won't be a 100% trivial rebase, it shouldn't be too onerous, I hope. |
arielb1
force-pushed the
arielb1:elaborate-drops
branch
from
325c3b7
to
129c4b5
May 17, 2016
This comment has been minimized.
This comment has been minimized.
|
rebased on top of #33667 |
nikomatsakis
reviewed
May 18, 2016
| DropAndReplace { target, unwind: Some(unwind), .. } | | ||
| Drop { target, unwind: Some(unwind), .. } => | ||
| vec![target, unwind].into_cow(), | ||
| DropAndReplace { ref target, .. } | Drop { ref target, .. } => |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
May 18, 2016
Contributor
Nit: can you write unwind: None here to make this more robust against accidental re-ordering? (and more obvious, I missed the lines above for a while)
nikomatsakis
reviewed
May 18, 2016
| Drop { ref mut target, unwind: Some(ref mut unwind), .. } => vec![target, unwind], | ||
| DropAndReplace { ref mut target, .. } | | ||
| Drop { ref mut target, .. } => vec![target] |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
reviewed
May 18, 2016
| repr::TerminatorKind::Drop { ref target, location: _, unwind: Some(ref unwind) } | | ||
| repr::TerminatorKind::DropAndReplace { | ||
| ref target, value: _, location: _, unwind: Some(ref unwind) | ||
| } => { | ||
| self.propagate_bits_into_entry_set_for(in_out, changed, target); | ||
| self.propagate_bits_into_entry_set_for(in_out, changed, unwind); |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
May 18, 2016
Contributor
I guess I'll see how this works out; but I'm a bit surprised that we don't wind up with some careful logic around the unwind path. In particular it might be that location is uninitialized before (and only initialized on the success path), no?
This comment has been minimized.
This comment has been minimized.
arielb1
May 18, 2016
Author
Contributor
location is initialized in both paths - that's the point of #30380.
This comment has been minimized.
This comment has been minimized.
|
fixed nit |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Jun 4, 2016
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Looks like an LLVM bug. See gist: https://gist.github.com/arielb1/8717eeaf5ac80fc4125e118729b5cb0c |
This comment has been minimized.
This comment has been minimized.
|
Blocked on LLVM bug https://llvm.org/bugs/show_bug.cgi?id=28005 |
This comment has been minimized.
This comment has been minimized.
|
@arielb1 I'm not sure we can afford to wait for that to get fixed. Any chance we can work around it? |
This comment has been minimized.
This comment has been minimized.
|
I’m having a hard time reproducing the issue in the gist it with the Arch’s 3.8 build of LLVM, which suggests that perhaps our own fork of LLVM went wrong somewhere? |
This comment has been minimized.
This comment has been minimized.
|
Claimed to be fixed in llvm-mirror/llvm@8c4b617, I've backported it to our branch (rust-lang/llvm@80ad955), so @arielb1 wanna try updating and see if that fixes it? |
This comment has been minimized.
This comment has been minimized.
|
I manually-applied the fix and am testing whether it works. That error is fixed, but there is a different error from a different pass (now I make it to the codegen passes). |
arielb1
force-pushed the
arielb1:elaborate-drops
branch
from
c183dcb
to
4106ab2
Jun 5, 2016
This comment has been minimized.
This comment has been minimized.
|
Ok, just lemme know if anything needs backporting! These MSVC bugs have really bitten me in the past in terms of taking quite a long time to track down, but once you have a minimal IR reproduction it's generally ready to get reported to LLVM. |
This comment has been minimized.
This comment has been minimized.
Calling |
This comment has been minimized.
This comment has been minimized.
|
Oh that's actually a red herring, it'll pass fine on the Windows bots. If you cross from Linux to Windows, you'll get that error, though. That's fixed in upstream LLVM we just haven't backported the fix yet. |
This comment has been minimized.
This comment has been minimized.
|
@bors r=nikomatsakis |
This comment has been minimized.
This comment has been minimized.
|
|
arielb1 commentedMay 13, 2016
•
edited
This enables non-zeroing drop through stack flags for MIR.
Fixes #30380.
Fixes #5016.