Skip to content

[NoncopyableWrapperElim] Process undef values. #74298

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 8 commits into from
Jun 12, 2024

Conversation

nate-chandler
Copy link
Contributor

Factored out common code path that records instructions that use values of noncopyable wrapped type and called it for the undef values in a function. Fixes a SIL verification error.

rdar://129593468

return {undefValues.begin(), undefValues.end()};
}

void updateTypeForUndef(SILUndef *undef, SILType oldType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's strange for an API called "updateType" to be passed the old value for the type. It makes more sense to pass the old and new undef values instead and call it "replaceUndef", or pass the old and new types and call it "replaceUndefType"

I can't make a suggestion beyond that because I don't understand where and how the undef's type actually changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or pass the old and new types and call it "replaceUndefType"

Fixed.

where and how the undef's type actually changes

The same way as every other value this pass modifies: unsafelyEliminateMoveOnlyWrapper.

Copy link
Contributor

Choose a reason for hiding this comment

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

The same way as every other value this pass modifies: unsafelyEliminateMoveOnlyWrapper.

Ok, looking at this one commit at a time, it wasn't clear that recordValue(pair.second) actually updates types. It sounds like it's actually recording the value for later update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the name to visitValue and added a short comment. Also, used RAUW for undefs because there might already be an undef of the unwrapped type in the function's undef map.

removing...To -> removing...From
This predicate is used in several places.
Replaced copy-pasted code with a twice-invoked closure.  In preparation
to add a third invocation.
The modified arguments were recorded but never used.
Such values' types may also also be move-only wrapped.
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler
Copy link
Contributor Author

@swift-ci please test source compatibility

@nate-chandler
Copy link
Contributor Author

@swift-ci please apple silicon benchmark

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Phew good catch. LGTM

@nate-chandler nate-chandler merged commit 3aca85b into swiftlang:main Jun 12, 2024
8 checks passed
@nate-chandler nate-chandler deleted the rdar129593468 branch June 12, 2024 13:55
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