Skip to content

[SIL Optimization] Factor out a utility function: isConsumingUse from CopyPropagation.cpp into InstOptUtils.cpp. #27794

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

Conversation

ravikandhadai
Copy link
Contributor

The function checks if a given use of a non-trivial, non-address SILValue will consume it
i.e., decrease its reference count.

This function will be used by the OSLogOptimization pass while constant folding values. See this PR: #27744, function replaceAllUsesAndFixLifetimes.

from CopyPropagation.cpp into InstOptUtils.cpp. The function checks
if a given use of a non-trivial, non-address SILValue will consume it
i.e., decrease its reference count.
@ravikandhadai
Copy link
Contributor Author

@swift-ci Please test

@eeckstein
Copy link
Contributor

@gottesmm @atrick Shouldn't we have this information via the tables in OperandOwnership.cpp?

@gottesmm
Copy link
Contributor

@eeckstein I was thinking about this last night. When I was looking at the other PR, I wasn't sure where to put this since traditionally OwnershipUtils was just for OSSA code. But over time for certain things that has changed especially around the linear lifetime checker, so maybe it does make sense to put the declaration of this in ownership utils.

Regardless of where we put this, I /do/ think that this should delegate to the OSSA tables if the function is in ownership SIL and then have a covered switch (or a table like thing) if we are not in OSSA. That way we get nice warnings/errors when we add new instructions.

Still thinking about this a little though.

@ravikandhadai
Copy link
Contributor Author

@gottesmm @atrick Shouldn't we have this information via the tables in OperandOwnership.cpp?

@eeckstein If we are in ownership SIL yes this is exactly same as "MustBeInvalidated" flag of OperandOwnership Tables. But, I would like to also get this information when I am in non-ownership SIL. That is, I would like to know which operations are decrementing reference counts. I found that such a function was used in CopyPropagation.cpp. Perhaps like @gottesmm mentioned we need a better naming convention to indicate that this function can be used on OSSA and non-OSSA as well.

@ravikandhadai
Copy link
Contributor Author

Closing this PR as this utility is not needed by the OSLogOptimization pass any more.

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