Open
Description
Description
copy propagation in optimized builds scales poorly on code with large basic blocks, and can end up taking a very long time to compile due to redundant work when canonicalizing OSSA lifetimes.
Reproduction
using code of the following form:
final class A {}
final class B {
let prop1: A
let prop2: A
...
let propN: A
init() {
self.prop1 = switch () { default: A() }
self.prop2 = switch () { default: A() }
...
self.propN = switch () { default: A() }
}
}
build with:
swiftc -swift-version 5 -O -emit-sil <file>
build takes ~3.5 minutes with 1024 properties and scales up to ~43 minutes with 2048 properties
Expected behavior
compile time should increase more slowly on these examples.
Environment
Apple Swift version 6.2 (swiftlang-6.2.0.9.909 clang-1700.3.9.907)
Target: arm64-apple-macosx15.0
Additional information
more details can be found in this forum thread: https://forums.swift.org/t/poor-scaling-with-optimized-builds-involving-ossa-copy-propagation-in-the-6-2-compiler/80436