Skip to content

Two optimization improvements to fix dead-object-elimination with OSSA #78163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 13, 2024

Conversation

eeckstein
Copy link
Contributor

  • DeadObjectElimination: handle begin_borrow/end_borrow when deleting dead arrays

  • add simplification for fix_lifetime: canonicalize a fix_lifetime from an address to a load + fix_lifetime:

   %1 = alloc_stack $T
   ...
   fix_lifetime %1

->

   %1 = alloc_stack $T
   ...
   %2 = load %1
   fix_lifetime %2

This peephole optimization was already done in SILCombine, but it didn't handle store_borrow - a good opportunity to make an instruction simplification out of it.

This is part of fixing regressions when enabling OSSA modules:
rdar://140229560

…ead arrays

This is part of fixing regressions when enabling OSSA modules:
rdar://140229560
Canonicalize a `fix_lifetime` from an address to a `load` + `fix_lifetime`:
```
   %1 = alloc_stack $T
   ...
   fix_lifetime %1
```
->
```
   %1 = alloc_stack $T
   ...
   %2 = load %1
   fix_lifetime %2
```

This transformation is done for `alloc_stack` and `store_borrow` (which always has an `alloc_stack` operand).
The benefit of this transformation is that it enables other optimizations, like mem2reg.

This peephole optimization was already done in SILCombine, but it didn't handle store_borrow.
A good opportunity to make an instruction simplification out of it.

This is part of fixing regressions when enabling OSSA modules:
rdar://140229560
@eeckstein eeckstein requested review from nate-chandler, meg-gupta and atrick and removed request for nate-chandler December 13, 2024 11:09
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein
Copy link
Contributor Author

@swift-ci benchmark

Copy link
Contributor

@meg-gupta meg-gupta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@eeckstein eeckstein merged commit 55009bf into swiftlang:main Dec 13, 2024
6 checks passed
@eeckstein eeckstein deleted the improve-dead-object-elimination branch December 13, 2024 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants