Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upMark &mut pointers as noalias once LLVM no longer miscompiles them #31681
Comments
bstrie
added
A-LLVM
A-codegen
A-optimization
labels
Feb 15, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jplatte
Feb 18, 2016
Contributor
Was just reading about this, and it was a little hard to find the LLVM bug report, so for reference, here it is.
|
Was just reading about this, and it was a little hard to find the LLVM bug report, so for reference, here it is. |
eefriedman
referenced this issue
May 9, 2016
Closed
Performance issue in `write_all` (`Vec::extend_from_slice`) #33518
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
eefriedman
May 31, 2016
Contributor
I've been working through the LLVM optimization passes to find noalias-related bugs. Known issues:
https://bugs.llvm.org/show_bug.cgi?id=25422Fixedhttps://bugs.llvm.org/show_bug.cgi?id=27849Fixedhttps://bugs.llvm.org/show_bug.cgi?id=27857Fixedhttps://bugs.llvm.org/show_bug.cgi?id=27858Fixedhttps://bugs.llvm.org/show_bug.cgi?id=27859Fixedhttps://bugs.llvm.org/show_bug.cgi?id=27860Fixedhttps://bugs.llvm.org/show_bug.cgi?id=27952Fixedhttps://bugs.llvm.org/show_bug.cgi?id=27953Fixed
Some of these are less important because they can't caused a wrong value, only a segfault.
There are probably a few more lurking issues, but hopefully I've found most of them.
(Edited by bluss 2016-12-15 to strike out fixed bug)
(Edited by mbrubeck 2017-03-30 to link to new LLVM bugzilla domain)
(Edited by scottmcm 2018-03-29 to strike out fixed bug)
|
I've been working through the LLVM optimization passes to find noalias-related bugs. Known issues:
Some of these are less important because they can't caused a wrong value, only a segfault. There are probably a few more lurking issues, but hopefully I've found most of them. (Edited by bluss 2016-12-15 to strike out fixed bug) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@eefriedman LLVM bug 27859 is closed. |
added a commit
to bluss/rust
that referenced
this issue
Sep 8, 2016
added a commit
to bluss/rust
that referenced
this issue
Sep 8, 2016
added a commit
to bluss/rust
that referenced
this issue
Sep 8, 2016
bluss
referenced this issue
Sep 8, 2016
Merged
Work around pointer aliasing issue in Vec::extend_from_slice, extend_with_element #36355
added a commit
to bluss/rust
that referenced
this issue
Sep 8, 2016
added a commit
to bluss/rust
that referenced
this issue
Sep 8, 2016
added a commit
to bluss/rust
that referenced
this issue
Sep 9, 2016
added a commit
that referenced
this issue
Sep 12, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
gnzlbg
Sep 15, 2016
Contributor
@eefriedman bug 25422 should be fixed.
Any progress on bug 27860 ?
(Edited by mbrubeck 2017-03-30 to link to new LLVM bugzilla domain)
|
@eefriedman bug 25422 should be fixed. Any progress on bug 27860 ? (Edited by mbrubeck 2017-03-30 to link to new LLVM bugzilla domain) |
bluss
referenced this issue
Jan 9, 2017
Open
Missed optimization: references from pointers aren't treated as noalias #38941
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pmarcelll
Jan 16, 2017
Contributor
NewGVN was recently merged into LLVM (still experimental), it's a rewrite of the global value numbering algorithm. The last remaining bug on our list is bug in the old gvn implementation. I compiled the example codes in the bug report with the new gvn algorithm, and they work fine, so hopefully LLVM 5.0 will stabilize NewGVN and we can turn this optimization back on.
EDIT: NewGVN integration into LLVM tracked here
|
NewGVN was recently merged into LLVM (still experimental), it's a rewrite of the global value numbering algorithm. The last remaining bug on our list is bug in the old gvn implementation. I compiled the example codes in the bug report with the new gvn algorithm, and they work fine, so hopefully LLVM 5.0 will stabilize NewGVN and we can turn this optimization back on. |
Mark-Simulacrum
removed
the
A-optimization
label
Jun 23, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jrmuizel
Jul 20, 2017
Contributor
I talked with Davide Italiano from LLVM and the goal is for NewGVN to be turned on in LLVM 6.0.
Given that and the fact that https://bugs.llvm.org//show_bug.cgi?id=27860 also affects code that doesn't use restrict/noalias I wonder if we could try turning this on? Even if we could only use this when compiling in panic=abort mode (as it seems many of the codegen issues were related to exceptions).
#42047 is a reduced test case of a real performance problem that's helped by this that we're running into with WebRender so it would be nice to fix this sooner rather than later.
|
I talked with Davide Italiano from LLVM and the goal is for NewGVN to be turned on in LLVM 6.0. #42047 is a reduced test case of a real performance problem that's helped by this that we're running into with WebRender so it would be nice to fix this sooner rather than later. |
jrmuizel
referenced this issue
Jul 20, 2017
Open
WebRender has a bad time with https://jrmuizel.github.io/perf-tests/moving-balls.html #1501
Mark-Simulacrum
added
the
C-enhancement
label
Jul 24, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Vurich
Aug 2, 2017
I support enabling this if and only if panic = "abort". Even if having the codegen be different depending on panic mode is not currently supported it would be something deserving of an RFC in my opinion, since there are a bunch of possible optimisations that this could enable, like removing zeroing when initialising an array.
Maybe if "treat function calls as possible branch point" is a function-level annotation in LLVM the only difference would be emitting/not emitting that.
Vurich
commented
Aug 2, 2017
•
|
I support enabling this if and only if Maybe if "treat function calls as possible branch point" is a function-level annotation in LLVM the only difference would be emitting/not emitting that. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jrmuizel
Aug 4, 2017
Contributor
Is it possible for us to get a cargobomb run with the patch reverted to see if we trigger any bad codegen?
|
Is it possible for us to get a cargobomb run with the patch reverted to see if we trigger any bad codegen? |
kennytm
referenced this issue
Aug 5, 2017
Open
Performance: fails to inline struct field access and keep it in the register. #43653
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
dpc
Aug 5, 2017
Contributor
Any best guesses when this improvement would be available in Rust nightly (with and without panic = "abort")? It would affect the design and implementation of performance critical crates I'm working on. If it's couple of months, it might be worth waiting. If it's a year, it might be worth to workaround in the code.
|
Any best guesses when this improvement would be available in Rust nightly (with and without |
durka
referenced this issue
Aug 6, 2017
Closed
Full name display breaks on comments edited by someone else #656
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
arielb1
Aug 6, 2017
Contributor
Is PR27860 actually a problem for Rust? I think every time we emit noalias we also emit dereferencable. Unless LLVM considers every GEP of the pointer as dereferencable, even in the presence of e.g. bounds checks (oops).
|
Is PR27860 actually a problem for Rust? I think every time we emit |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
arielb1
Aug 6, 2017
Contributor
PR27860 is actually a problem even with &-references - this segfaults:
#![feature(test)]
extern crate test;
extern "C" {
fn abort();
}
#[no_mangle]
#[inline(never)]
pub fn abuseme(x: &[u8]) -> u8 {
if x.len() > 0x10000000000 {
test::black_box(x[0x10000000000]);
}
unsafe { abort(); }
unsafe { *x.get_unchecked(0x10000000000) }
}
fn main() {
abuseme(&[]);
}|
PR27860 is actually a problem even with #![feature(test)]
extern crate test;
extern "C" {
fn abort();
}
#[no_mangle]
#[inline(never)]
pub fn abuseme(x: &[u8]) -> u8 {
if x.len() > 0x10000000000 {
test::black_box(x[0x10000000000]);
}
unsafe { abort(); }
unsafe { *x.get_unchecked(0x10000000000) }
}
fn main() {
abuseme(&[]);
} |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Vurich
Aug 8, 2017
@arielb1 Does that violate Rust's guarantees though? I don't know that there's any guarantees about reordering when it comes to calling extern functions. What happens if you explicitly annotate the type as fn abort() -> !?
Vurich
commented
Aug 8, 2017
•
|
@arielb1 Does that violate Rust's guarantees though? I don't know that there's any guarantees about reordering when it comes to calling extern functions. What happens if you explicitly annotate the type as |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
arielb1
Aug 9, 2017
Contributor
Of course there are guarantees about reordering about extern functions - otherwise read etc. would never work. You could also replace the abort with a read of a forever-empty pipe or something to avoid it needing to be annotated with !.
|
Of course there are guarantees about reordering about extern functions - otherwise |
arielb1
closed this
Aug 9, 2017
arielb1
reopened this
Aug 9, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
oyvindln
Aug 9, 2017
Contributor
I support enabling this if and only if panic = "abort".
Maybe a -Z enable-noalias or similar option could be added as a start to make it easier to test where the lack of noalias makes a difference.
Maybe a |
bstrie
added
the
I-slow
label
Sep 15, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
matthiaskrgr
Sep 15, 2017
Contributor
@oyvindln if you want to turn on newgvn to compare things, RUSTFLAGS="-C llvm-args=-enable-newgvn" might work.
|
@oyvindln if you want to turn on newgvn to compare things, RUSTFLAGS="-C llvm-args=-enable-newgvn" might work. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pcwalton
Sep 28, 2017
Contributor
It's unclear from reading this what the state of this bug is. Do we still believe that NewGVN will fix this issue?
|
It's unclear from reading this what the state of this bug is. Do we still believe that NewGVN will fix this issue? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
arielb1
Sep 28, 2017
Contributor
I think all "noalias-exclusive" bugs are fixed, so it might be worth giving it a try and opening a PR.
|
I think all "noalias-exclusive" bugs are fixed, so it might be worth giving it a try and opening a PR. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Does that enablement need to be conditional on LLVM version? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
I think. 4.0 should be fine. |
steveklabnik
referenced this issue
Sep 30, 2017
Open
make use of LLVM's scoped noalias metadata #16515
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bstrie
Oct 20, 2017
Contributor
Update: there's now a -Z flag for opting-in to this on an experimental basis: #45012. It also seems as though the behavior is enabled by default for panic=abort builds. However, I think this might be worth keeping open until we concretely determine whether or not we'll be able to turn this on for panic=unwind builds (see #45029 ).
|
Update: there's now a -Z flag for opting-in to this on an experimental basis: #45012. It also seems as though the behavior is enabled by default for panic=abort builds. However, I think this might be worth keeping open until we concretely determine whether or not we'll be able to turn this on for panic=unwind builds (see #45029 ). |
dotdash
referenced this issue
Nov 29, 2017
Open
Unnecessary memcpy during struct initialization #45663
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
alexbool
Feb 11, 2018
Contributor
What's the state of this given that LLVM has been upgraded to 6.0?
|
What's the state of this given that LLVM has been upgraded to 6.0? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
To help finding this issue: the -Z flag is |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
scottmcm
Mar 30, 2018
Member
Looks like the last part of the checklist above landed with https://reviews.llvm.org/D38619#937247
|
Looks like the last part of the checklist above landed with https://reviews.llvm.org/D38619#937247 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
nox
Apr 2, 2018
Contributor
Should we make a PR to always enable mutable_noalias and see what happens on the CI and Crater?
|
Should we make a PR to always enable |
RalfJung
referenced this issue
May 14, 2018
Open
mutable noalias: re-enable permanently, only for panic=abort, or stabilize flag? #45029
added a commit
to nikic/rust
that referenced
this issue
May 14, 2018
added a commit
to nikic/rust
that referenced
this issue
May 14, 2018
added a commit
to nikic/rust
that referenced
this issue
May 14, 2018
added a commit
to nikic/rust
that referenced
this issue
May 14, 2018
added a commit
to nikic/rust
that referenced
this issue
May 17, 2018
added a commit
to nikic/rust
that referenced
this issue
May 17, 2018
added a commit
that referenced
this issue
May 19, 2018
added a commit
that referenced
this issue
May 19, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
As #50744 has landed, this can be closed. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
|
bstrie commentedFeb 15, 2016
This issue tracks the undoing of the workaround introduced in #31545 on account of a bug in LLVM. cc @dotdash