mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Try to replace a begin_borrow with its owned operand. This is either possible if the borrowed value (or a forwarded value if it) is copied: ``` %1 = begin_borrow %0 %2 = struct_extract %1 // a chain of forwarding instructions %3 = copy_value %1 // ... uses of %3 end_borrow %1 ``` -> ``` %1 = copy_value %0 %3 = destructure_struct %0 // owned version of the forwarding instructions // ... uses of %3 ``` Or if the borrowed value is destroyed immediately after the borrow scope: ``` %1 = begin_borrow %0 %2 = struct_extract %1 // a chain of forwarding instructions // ... uses of %2 end_borrow %1 destroy_value %1 // the only other use of %0 beside begin_borrow ``` -> ``` %2 = destructure_struct %0 // owned version of the forwarding instructions // ... uses of %2 destroy_value %2 ```