Skip to content

Conversation

@eeckstein
Copy link
Contributor

This pass removes copy_addr instructions.
However, it has some problems which causes compiler crashes.
It's not worth fixing these bugs because

  1. Most copy_addrs can be eliminated by TempRValueElimination and TempLValueElimination.
  2. Once we have opaque value we don't need copy_addr elimination, anyway.

This PR also contains some improvements for TempRValueElimination to compensate for the missing CopyForwarding pass.

rdar://162212460

@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

@eeckstein
Copy link
Contributor Author

@swift-ci apple silicon benchmark

@slavapestov
Copy link
Contributor

I'm loving all these PRs that are removing redundant/unused/marginal optimizer passes from the pipeline. Great job!

case SILInstructionKind::CopyAddrInst: {
auto *ca = cast<CopyAddrInst>(inst);
if (ca->getSrc()->getType().isTrivial(ca->getFunction()))
if (!ca->getSrc()->getType().hasArchetype())
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this case still need refcounting effect ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, thanks!
I fixed it

It only needs metadata if the copied type has an archetype
This pass removes `copy_addr` instructions.
However, it has some problems which causes compiler crashes.
It's not worth fixing these bugs because
1. Most copy_addrs can be eliminated by TempRValueElimination and TempLValueElimination.
2. Once we have opaque value we don't need copy_addr elimination, anyway.

rdar://162212460
@eeckstein eeckstein force-pushed the remove-copy-forwarding branch from f5f159a to 7a70049 Compare October 20, 2025 18:20
@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

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 9074a1e into swiftlang:main Oct 21, 2025
3 checks passed
@eeckstein eeckstein deleted the remove-copy-forwarding branch October 21, 2025 05:24
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.

3 participants