Skip to content

Backport LLVM fixes for a JumpThreading / assume intrinsic bug #48583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1246,18 +1246,15 @@ macro_rules! iterator {
{
// The addition might panic on overflow
// Use the len of the slice to hint optimizer to remove result index bounds check.
let _n = make_slice!(self.ptr, self.end).len();
let n = make_slice!(self.ptr, self.end).len();
self.try_fold(0, move |i, x| {
if predicate(x) { Err(i) }
else { Ok(i + 1) }
}).err()
// // FIXME(#48116/#45964):
// // This assume() causes misoptimization on LLVM 6.
// // Commented out until it is fixed again.
// .map(|i| {
// unsafe { assume(i < n) };
// i
// })
.map(|i| {
unsafe { assume(i < n) };
i
})
}

#[inline]
Expand All @@ -1274,13 +1271,10 @@ macro_rules! iterator {
if predicate(x) { Err(i) }
else { Ok(i) }
}).err()
// // FIXME(#48116/#45964):
// // This assume() causes misoptimization on LLVM 6.
// // Commented out until it is fixed again.
// .map(|i| {
// unsafe { assume(i < n) };
// i
// })
.map(|i| {
unsafe { assume(i < n) };
i
})
}
}

Expand Down