Skip to content

[NFC] cleanup Instruction/Value.findVarDecl() APIs #81290

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
May 6, 2025

Conversation

atrick
Copy link
Contributor

@atrick atrick commented May 5, 2025

No description provided.

@atrick
Copy link
Contributor Author

atrick commented May 5, 2025

@swift-ci smoke test

@atrick atrick enabled auto-merge May 5, 2025 21:29
@atrick atrick requested a review from eeckstein as a code owner May 5, 2025 21:59
@atrick
Copy link
Contributor Author

atrick commented May 5, 2025

@swift-ci smoke test

@atrick atrick changed the title [NFC] fix a comment typo in LifetimeDependence [NFC] cleanup Instruction/Value.findVarDecl() APIs May 6, 2025
@atrick atrick requested review from eeckstein and removed request for eeckstein May 6, 2025 03:59
@atrick atrick force-pushed the lifedep-comment-typo branch from 7853def to 0f67711 Compare May 6, 2025 04:03
@atrick
Copy link
Contributor Author

atrick commented May 6, 2025

@swift-ci smoke test

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

@eeckstein eeckstein disabled auto-merge May 6, 2025 05:34
These APIs are quite convoluted. The checks for var_decl need to be performed in
just the right order. The is a consequence of complexity in the SIL
representation itself, not a problem with the APIs.

It is common for code to accidentally call a less-complete form of the API. It
is essential that they be defined in a central location, and the we get the same
answer whether we start with an Instruction, Argument, or Value. The primary
public interface should always check for debug_value users. The varDecl property
is actually an implementation detail.

It is questionable whether a function like findVarDecl() that returns a basic
property of SIL and does not require arguments should be a property instead. It
is a function to hint that it may scan the use-list, which is not something
we normally want SIL properties to do. Use-lists can grow linearly in function
size. But, again, this is a natural result of the SIL representation and needs
to be considered an implementation detail.
@atrick atrick force-pushed the lifedep-comment-typo branch from 0f67711 to 170c563 Compare May 6, 2025 05:51
@atrick
Copy link
Contributor Author

atrick commented May 6, 2025

@swift-ci smoke test

@atrick atrick enabled auto-merge May 6, 2025 05:51
@atrick atrick merged commit 74e4078 into swiftlang:main May 6, 2025
3 checks passed
@atrick atrick deleted the lifedep-comment-typo branch May 6, 2025 16:11
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