-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[5.1] SILOptimier: Fix a miscompile in COWArrayOpt. #23431
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
eeckstein
merged 1 commit into
swiftlang:swift-5.1-branch
from
eeckstein:fix-cowarrayopt-5.1
Mar 20, 2019
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 hidden or 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 hidden or 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 hidden or 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,35 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: %target-build-swift -O %s -o %t/a.out | ||
// RUN: %target-run %t/a.out | %FileCheck %s | ||
|
||
// REQUIRES: executable_test | ||
|
||
// Check that the compiled code does not crash because of an over-release. | ||
// End-to-end test for rdar://problem/48906146. | ||
|
||
struct LCRNG: RandomNumberGenerator { | ||
private var state: UInt64 | ||
|
||
init(seed: Int) { | ||
state = UInt64(truncatingIfNeeded: seed) | ||
for _ in 0..<10 { _ = next() } | ||
} | ||
|
||
mutating func next() -> UInt64 { | ||
state = 2862933555777941757 &* state &+ 3037000493 | ||
return state | ||
} | ||
} | ||
|
||
|
||
func test(_ body: () -> Void) { | ||
body() | ||
} | ||
|
||
test { | ||
var rng = LCRNG(seed: 42) | ||
let v = Array(0..<3).shuffled(using: &rng) | ||
// CHECK: 3 | ||
print(v.count) | ||
} | ||
|
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.
I don't see an obvious connection between the comment and the test case. Here's my guess at how it works... For potentially aliased arrays, I think it's this pass' job to determine that a potential alias can't be accessed on any path from the loop header that does not pass through the original make_mutable. I guess we already do that within the loop but never checked outside the loop?
That isn't clear from the comment. Shouldn't it say something like:
I'm not sure if the above is actually true but at least it makes sense to me.
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.
Yes, that's probably a better way to describe it.