Skip to content

[6.0] FieldSensitivePrunedLiveness: Handle conditionality of try_apply defs. #72453

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

jckarter
Copy link
Contributor

@jckarter jckarter commented Mar 20, 2024

A `try_apply` with indirect out arguments is only a def for those arguments on
the success path. Model this by sinking the def-ness of the instruction into the
success branch of the try_apply, and introducing a new `DeadToLiveEdge` mode for
block liveness which stops propagation of use-before-def conditions into the
block that introduced the def. Fixes rdar://118567869.
@jckarter jckarter requested a review from a team as a code owner March 20, 2024 14:44
@jckarter jckarter requested a review from gottesmm March 20, 2024 14:45
@jckarter
Copy link
Contributor Author

@swift-ci Please test

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

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

LGTM. One little quip about how some code could be clearer. Also, can you look at on main why the MemoryLifetimeVerifier didn't catch this?

initializeDefBlock(block, span);
auto defBlock = getDefinedInBlock(node);
defBlocks.insert(defBlock, span);
initializeDefBlock(defBlock, span);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am fine fixing this on main in a forthcoming commit.

I find the logic here hides what is actually happening. First getDefinedInBlock(node) has a special case for try_apply and then we have here another special case below for try_apply. Why not just do something conditional on try_apply here. Then it is clear where all of the special case code is. That being said, I see you used getDefinedInBlock later in the patch, so maybe it makes sense to do this... IDK. Just reads weird to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I went back and forth on whether to use getDefinedInBlock here. Maybe it's premature, but I was also trying to think about how to systematically handle these sorts of def-on-edge cases if any more come up; if it does then having getDefinedInBlock already be here and used in more than one place seems like a good thing.

@jckarter jckarter merged commit cfbb82d into swiftlang:release/6.0 Mar 21, 2024
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