mirror of
https://github.com/apple/swift.git
synced 2026-01-07 22:52:31 +01:00
Once the algorithm has begun hoisting destroys globally, there's no way to cleanly bailout. The previous attempt to bailout could result in an assert or lost destroy in release mode. This is continued fall-out from changes in the previous release to upstream SILGen or mandatory passes, such as PredictableMemOps, that no longer preserve natural variable lifetimes. In this case, we end up with SIL like this before CopyForwarding: bb(%arg) %local_addr = alloc_stack store %arg to %local_addr %payload = switch_enum(%arg) retain %arg store %arg to %some_addr destroy_addr %local_addr release_value %arg We're attempting to hoist the destroy_addr to its last use, but can't because the lifetimes of the alloc_stack (%local_addr) and the value being stored on the stack (%arg) have become mixed up by an upstream pass. We actually detect this situation now in order to bail-out of destroy hoisting. Sadly, the bailout might only partially recover in the case of interesting control flow, as happens in the test case's Graph.init function. This triggers an assert, but in release mode it simply drops the destroy. Fixed <rdar://problem/43888666> [SR-8526]: Memory leak after switch in release configuration.
64 KiB
64 KiB