Skip to content

Conversation

@eeckstein
Copy link
Contributor

Don't complain if the empty array buffer singleton is set to mutable.
This can happen if reserveCapacity is called with a 0-capacity for an empty array.
In this case the resulting array is still the empty array singleton.
For the compiler, it's safe to treat the empty array singleton as "mutable", because there is never anything written to an array with zero capacity:
all mutating array operations do any form of capacity/size > 0 check in addition to the uniqueness check.

Unfortunately the empty array singleton sometimes needs such special handling with is not obvious (not to say hacky).

This wrong check only fired in very specific optimization scenarios, where the inliner and the COW optimizations must play together in a certain way.
I could not find an isolated test case for this problem.

rdar://problem/71107908

Don't complain if the empty array buffer singleton is set to mutable.
This can happen if reserveCapacity is called with a 0-capacity for an empty array.
In this case the resulting array is still the empty array singleton.
For the compiler, it's safe to treat the empty array singleton as "mutable", because there is never anything written to an array with zero capacity:
all mutating array operations do any form of capacity/size > 0 check in addition to the uniqueness check.

Unfortunately the empty array singleton sometimes needs such special handling with is not obvious (not to say hacky).

This wrong check only fired in very specific optimization scenarios, where the inliner and the COW optimizations must play together in a certain way.
I could not find an isolated test case for this problem.

rdar://problem/71107908
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein merged commit b714a31 into swiftlang:main Nov 9, 2020
@eeckstein eeckstein deleted the fix-cow-checks branch November 9, 2020 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant