[SR-14516] Swift generates subscript.read accessors that allocate! #56868
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
regression
SILOptimizer
Area → compiler: SIL optimization passes
swift 5.4
Attachment: Download
Environment
Apple Swift version 5.4 (swiftlang-1205.0.22.2 clang-1205.0.19.29)
Additional Detail from JIRA
md5: 06a0e70a5391143833033eeeb67e35f7
Issue Description:
The following (sorry, this used to be 1700 lines, and
creduce
reduced this) program allocates 10,000 times:here's how it goes:
b.F
callsb.first
(which is provided automatically from Collection)b.first
calls the subscript's read accessor which has an unconditionalmalloc
(for coroutines I think) in there 🙁the read accessors really shouldn't allocate as that defeats many other optimisations.
Full program attached.
Repro:
See how we get 10,000 allocations (malloc) through the subscript.read by calling F 10,000 times?
This seems to be a Swift 5.4 regression. We found this issue in the NIO CI which regresses allocations in a few allocation counter tests but only in 5.4.
Also affects
In case you're into
creduce
, this is the interestingness test I used (for Linux)The text was updated successfully, but these errors were encountered: