Skip to content

SIL: Fix memory behavior of mark_dependence #79110

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 3 commits into from
Feb 11, 2025

Conversation

eeckstein
Copy link
Contributor

@eeckstein eeckstein commented Feb 3, 2025

If the base value of a mark_dependence is an address, that memory location must be initialized at the mark_dependence.
This requires that the mark_dependence is considered to read from the base address.

Also, verify that the base value is initialized in the MemoryLifetimeVerifier.
The check is not perfect, because it only checks that the base operand is alive at the mark_dependence. Ideally it should check that the base operand is alive during the whole lifetime of the value operand.

The verification uncovered a problem in TempRValueOptimization which is fixed by not optimizing copies to mark_dependence base values.

@eeckstein eeckstein requested a review from jckarter as a code owner February 3, 2025 11:47
@eeckstein eeckstein requested review from meg-gupta, atrick and nate-chandler and removed request for jckarter February 3, 2025 11:47
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein force-pushed the verify_mark_dependence branch from e128d90 to e9ce616 Compare February 10, 2025 08:09
@eeckstein eeckstein changed the title SIL: handle mark_dependence in the MemoryLifetimeVerifier SIL: Fix memory behavior of mark_dependence Feb 10, 2025
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein
Copy link
Contributor Author

@swift-ci benchmark

@eeckstein
Copy link
Contributor Author

@swift-ci test source compatibility

… values.

We want to keep the original lifetime of the base. If we would eliminate the base alloc_stack, we risk to insert a destroy_addr too early.
If the base value of a mark_dependence is an address, that memory location must be initialized at the mark_dependence.
This requires that the mark_dependence is considered to read from the base address.
The check is not perfect, because it only checks that the base operand is alive _at_ the mark_dependence.
Ideally it should check that the base operand is alive during the whole lifetime of the value operand.
@eeckstein eeckstein force-pushed the verify_mark_dependence branch from e9ce616 to 6a6d3f0 Compare February 10, 2025 16:58
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein merged commit aa0833b into swiftlang:main Feb 11, 2025
5 checks passed
@eeckstein eeckstein deleted the verify_mark_dependence branch February 11, 2025 05:39
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