Commit Graph

3 Commits

Author SHA1 Message Date
Erik Eckstein
b6e9c4c5e4 TempLValueElimination: don't propagate alloc_stack which have access scopes
If exclusivity is checked for the alloc_stack we must not replace it with the copy-destination.
If the copy-destination is also in an access-scope this would result in an exclusivity violation which was not there before.

Fixes a miscompile which results in a wrong exclusivity violation error at runtime.
https://github.com/swiftlang/swift/issues/83924
rdar://159220436
2025-08-30 07:29:15 +02:00
Erik Eckstein
abbe0e8e95 TempLValueElimination: fix a stupid bug when combining copy_addr with a following destroy_addr
This peephole optimization also combined the instructions if the `destroy_addr` appears before the `copy_addr` in the same basic block.

https://github.com/swiftlang/swift/issues/82466
rdar://154236276
2025-06-25 08:09:55 +02:00
Erik Eckstein
2b9b2d243c Optimizer: improve TempLValueOpt
* re-implement the pass in swift
* support alloc_stack liveranges which span over multiple basic blocks
* support `load`-`store` pairs, copying from the alloc_stack (in addition to `copy_addr`)

Those improvements help to reduce temporary stack allocations, especially for InlineArrays.

rdar://151606382
2025-06-05 06:45:18 +02:00