-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove some assume
s from slice iterators that don't do anything
#111282
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// no-system-llvm | ||
// compile-flags: -O | ||
// ignore-debug (these add extra checks that make it hard to verify) | ||
#![crate_type = "lib"] | ||
|
||
// The slice iterator used to `assume` that the `start` pointer was non-null. | ||
// That ought to be unneeded, though, since the type is `NonNull`, so this test | ||
// confirms that the appropriate metadata is included to denote that. | ||
|
||
// CHECK-LABEL: @slice_iter_next( | ||
#[no_mangle] | ||
pub fn slice_iter_next<'a>(it: &mut std::slice::Iter<'a, u32>) -> Option<&'a u32> { | ||
// CHECK: %[[ENDP:.+]] = getelementptr{{.+}}ptr %it,{{.+}} 1 | ||
// CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] | ||
// CHECK-SAME: !nonnull | ||
// CHECK-SAME: !noundef | ||
// CHECK: %[[START:.+]] = load ptr, ptr %it, | ||
// CHECK-SAME: !nonnull | ||
// CHECK-SAME: !noundef | ||
// CHECK: icmp eq ptr %[[START]], %[[END]] | ||
|
||
// CHECK: store ptr{{.+}}, ptr %it, | ||
|
||
it.next() | ||
} | ||
|
||
// CHECK-LABEL: @slice_iter_next_back( | ||
#[no_mangle] | ||
pub fn slice_iter_next_back<'a>(it: &mut std::slice::Iter<'a, u32>) -> Option<&'a u32> { | ||
// CHECK: %[[ENDP:.+]] = getelementptr{{.+}}ptr %it,{{.+}} 1 | ||
// CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] | ||
// CHECK-SAME: !nonnull | ||
// CHECK-SAME: !noundef | ||
// CHECK: %[[START:.+]] = load ptr, ptr %it, | ||
// CHECK-SAME: !nonnull | ||
// CHECK-SAME: !noundef | ||
// CHECK: icmp eq ptr %[[START]], %[[END]] | ||
|
||
// CHECK: store ptr{{.+}}, ptr %[[ENDP]], | ||
|
||
it.next_back() | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it matter which order the ptr comparison goes in? Sometimes LLVM likes to change that up a little.
Otherwise looks pretty good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, for
eq
the order shouldn't matter. I wonder if I can put the[[vars]]
in a regex to allow either order...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I definitely can't use a regex to allow either, since the
[[
syntax in regexes is character classes. Not sure how best to do this...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, yeah, I asked some LLVM devs and they basically were like "oh I dunno, I don't think we support that" so I think this is something we can't harden our tests against. Which isn't awful, I've seen operand swaps happen once or twice but that doesn't mean they're incredibly common.