Open drexin opened 5 years ago
attached screenshots of the assembly and SIL diffs between the the good ({{ let value = dict[x]}}) and bad (switch dict[x]
) versions. In both cases we see that the switch
appears to retain the whole dictionary the the whole switch
and in the good version it doesn't...
and it's still and issue in a very recent 5.1 snapshot and also in swift-DEVELOPMENT-SNAPSHOT-2019-05-12-a.xctoolchain
.
cc @gottesmm (possibly "fixed" by your redoing of SILGenPattern?)
Attachment: Download
Environment
Apple Swift version 5.0 (swift-5.0-RELEASE) Target: x86_64-apple-darwin18.5.0Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 1 | |Component/s | Compiler | |Labels | Bug, 5.0Regression, ARC, Optimizer | |Assignee | None | |Priority | Medium | md5: c994e96b09804105727b513a51ebc355relates to:
Issue Description:
When switching over the result of a dictionary lookup directly in Swift 5 and then modifying that dictionary it will be copied.
The above code allocates 1092 times in total.
When assigning the result to a variable first, it does not copy.
The above code allocates 91 times in total.
In Swift 4.2 both versions do not copy, so this seems to be a regression in Swift 5.