Commit Graph

4 Commits

Author SHA1 Message Date
Erik Eckstein
a4c675ec88 CopyToBorrowOptimization: fix insertion order of end_borrows
In liferange exit blocks the end_borrows were inserted in the wrong order.

Fixes an ownership verification error
rdar://142632741
2025-01-10 08:56:42 +01:00
Erik Eckstein
cd7c533d42 Optimizer: add SingleValueInstruction.replace(with:) and use it throughout the optimizer
It replaces all uses and then erases the instruction.
2024-12-19 20:53:45 +01:00
Erik Eckstein
bdd80aac26 CopyToBorrowOptimization: correctly handle uses in dead-end blocks when removing a copy_value
Fixes an ownership verifier crash
rdar://141278208
2024-12-16 09:44:31 +01:00
Erik Eckstein
dd78dc722b Optimizer: add an optimization to remove copy_value of a borrowed value.
It removes a `copy_value` where the source is a guaranteed value, if possible:

```
  %1 = copy_value %0   // %0 = a guaranteed value
  // uses of %1
  destroy_value %1     // borrow scope of %0 is still valid here
```
->
```
  // uses of %0
```

This optimization is very similar to the LoadCopyToBorrow optimization.
Therefore I merged both optimizations into a single file and renamed it to "CopyToBorrowOptimization".
2024-12-09 20:01:07 +01:00