Skip to content

[6.2] RedundantLoadElimination: support replacing a redundant copy_addr with a store #81131

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 1 commit into from
Apr 28, 2025

Conversation

eeckstein
Copy link
Contributor

  • Explanation: This is an optimization improvement for redundant-load-elimination. This is important to be able to create certain statically initialized globals in the mandatory pipeline, e.g. globals of type Range. It fixes a a very bad code generation regression in the https://github.com/apple/swift-mmio project.
  • Risk: medium: the optimization improvement itself is simple. However, because the optimization runs early in the pipeline it will affect all compiled code. And for such optimization changes it's impossible to rule out any unwanted side effects.
  • Testing: Tested by lit tests and it already lived for quite a while on the main branch without problems.
  • Issue: rdar://149356742
  • Reviewer: @meg-gupta
  • Main branch PR: RedundantLoadElimination: support replacing a redundant copy_addr with a store #80912

…ith a `store`

For example:
```
  %0 = load %1
  copy_addr %1 to %2
```
->
```
  %0 = load %1
  store %0 to %2
```

This is important for MandatoryRedundantLoadElimination to be able to create statically initialized globals in the mandatory pipeline.
For example:
```
public struct MyStruct {
  public static let r: Range<Int> = 1 ..< 3
}

```
gets a statically initialized global, even at Onone, with this improvement.

rdar://149356742
@eeckstein eeckstein requested a review from a team as a code owner April 28, 2025 06:13
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein merged commit ea4906d into swiftlang:release/6.2 Apr 28, 2025
5 checks passed
@eeckstein eeckstein deleted the copyaddr-in-rle-6.2 branch April 28, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants