-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
ARCFeature: automatic reference countingFeature: automatic reference countingSILOptimizerArea → compiler: SIL optimization passesArea → compiler: SIL optimization passesclosuresFeature: closuresFeature: closurescompilerThe Swift compiler itselfThe Swift compiler itselfexpressionsFeature: expressionsFeature: expressionsperformanceswift 6.2
Description
Description
The retain/release pair around the execute
call should be eliminated.
Discussion: https://forums.swift.org/t/why-does-swift-decide-to-insert-a-retain-release-pair-here
Reproduction
public class Object { var count = 0 }
@inline(never)
func execute<T>(closure: () -> T) -> T {
closure()
}
func compare(reference: Object, count: Int) -> Bool {
// retain Object
execute { reference.count == count }
// release Object
}
Expected behavior
no ARC traffic in this function
Environment
reproducible with top of main
Additional information
No response
mickeyl
Metadata
Metadata
Assignees
Labels
ARCFeature: automatic reference countingFeature: automatic reference countingSILOptimizerArea → compiler: SIL optimization passesArea → compiler: SIL optimization passesclosuresFeature: closuresFeature: closurescompilerThe Swift compiler itselfThe Swift compiler itselfexpressionsFeature: expressionsFeature: expressionsperformanceswift 6.2