Commit Graph

2 Commits

Author SHA1 Message Date
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