Skip to content

Commit

Permalink
Auto merge of #123602 - cjgillot:gvn-borrowed, r=oli-obk
Browse files Browse the repository at this point in the history
Account for immutably borrowed locals in MIR copy-prop and GVN

For the most part, we consider that immutably borrowed `Freeze` locals still fulfill SSA conditions. As the borrow is immutable, any use of the local will have the value given by the single assignment, and there can be no surprise.

This allows copy-prop to merge a non-borrowed local with a borrowed local. We chose to keep copy-classes heads unborrowed, as those may be easier to optimize in later passes.

This also allows to GVN the value behind an immutable borrow. If a SSA local is borrowed, dereferencing that borrow is equivalent to copying the local's value: re-executing the assignment between the borrow and the dereference would be UB.

r? `@ghost` for perf
  • Loading branch information
bors committed May 3, 2024
2 parents 2ecfdef + 4e9ed95 commit 35aa211
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 35aa211

Please sign in to comment.