Skip to content
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

Fix LifetimeDependenceScopeFixup to avoid rewriting mark_dependence. #78482

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Jan 7, 2025

This pass rewrites mark_depenendence to ignore "useless" borrow scopes. It was also accidentally rewriting a dependence on a loaded value, which may redirect the dependence to the access scope used to load that value. That access scope may be narrower than the lifetime of the loaded value which could result in invalid SIL. Do not rewrite this mark_dependence:

%access = begin_access [read] [unknown] %base
%load = load [trivial] %access
end_access %access
%adr = pointer_to_address
%md = mark_dependence [unresolved] %adr on %load

Fixes rdar://142424000 (Swift compiler crashes with Assertion failed (isa(block->getTerminator())))

This pass rewrites mark_depenendence to ignore "useless" borrow scopes. It was
also accidentally rewriting a dependence on a loaded value, which may redirect the
dependence to the access scope used to load that value. That access scope may be
narrower than the lifetime of the loaded value which could result in invalid
SIL. Do not rewrite this mark_dependence:

  %access = begin_access [read] [unknown] %base
  %load = load [trivial] %access
  end_access %access
  %adr = pointer_to_address
  %md = mark_dependence [unresolved] %adr on %load

Fixes rdar://142424000 (Swift compiler crashes with Assertion failed
(isa<UnreachableInst>(block->getTerminator())))
@atrick atrick requested a review from eeckstein as a code owner January 7, 2025 23:45
@atrick atrick requested a review from nate-chandler January 7, 2025 23:45
@atrick
Copy link
Contributor Author

atrick commented Jan 7, 2025

@swift-ci test

Copy link
Contributor

@nate-chandler nate-chandler left a comment

Choose a reason for hiding this comment

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

lgtm

@atrick atrick requested a review from jckarter as a code owner January 8, 2025 01:07
@atrick
Copy link
Contributor Author

atrick commented Jan 8, 2025

@swift-ci test

@atrick
Copy link
Contributor Author

atrick commented Jan 8, 2025

@swift-ci test source compatibility

@atrick
Copy link
Contributor Author

atrick commented Jan 8, 2025

@swift-ci benchmark

Recognize dependence on the address of a trivial 'var' as an "access" dependence
instead of an "unknown" dependence. This allows the mark_dependence to be
resolved as "[nonescaping]".
@atrick
Copy link
Contributor Author

atrick commented Jan 8, 2025

@swift-ci test

@atrick
Copy link
Contributor Author

atrick commented Jan 8, 2025

@swift-ci test source compatibility

@atrick atrick enabled auto-merge January 8, 2025 06:24
@atrick
Copy link
Contributor Author

atrick commented Jan 8, 2025

@swift-ci test

@atrick
Copy link
Contributor Author

atrick commented Jan 8, 2025

@swift-ci test source compatibility

1 similar comment
@atrick
Copy link
Contributor Author

atrick commented Jan 8, 2025

@swift-ci test source compatibility

@atrick atrick merged commit dd0e419 into swiftlang:main Jan 8, 2025
4 of 7 checks passed
@atrick atrick deleted the fix-markdep-load branch January 9, 2025 00:45
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