Skip to content

Fix OSSA RAUW utility's insertion point #64554

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
Mar 24, 2023

Conversation

meg-gupta
Copy link
Contributor

@meg-gupta meg-gupta commented Mar 22, 2023

This change ensures OSSA RAUW consistently inserts borrows before the old value. Before this it inserted new borrows before the old value only when it was in the same block as new value.
Since we can expect the users of OSSA RAUW have made sure that newValue will dominate oldValue, update the utility to always insert before the old value.

@meg-gupta
Copy link
Contributor Author

@swift-ci smoke test

@atrick
Copy link
Contributor

atrick commented Mar 23, 2023

It seems difficult to use the RAUW utility correctly in this respect. It's not obvious from reading the code why you need another builder. Is there any reason for prepareReplacement to be inserting fixup code for the incoming value after the old value instead of before the old value? I would either expect prepareReplacement to insert before the old value or to use the same insertion point as SILCombine. If they both use the same insertion point, then the instructions should be inserted in the correct order.

@meg-gupta
Copy link
Contributor Author

@atrick Right, thank you! There isn't any reason for prepareReplacement to be inserting after the oldValue. I updated the api and now all uses of OSSA RAUW api can consistently expect the new instructions to be inserted before oldValue.

@meg-gupta
Copy link
Contributor Author

@swift-ci smoke test

@meg-gupta meg-gupta changed the title Fix SILCombine of unchecked_bitwise_cast Fix OSSA RAUW utility to consistently insert borrows before the value to be replaced Mar 23, 2023
@meg-gupta meg-gupta changed the title Fix OSSA RAUW utility to consistently insert borrows before the value to be replaced Fix OSSA RAUW utility's insertion point Mar 23, 2023
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.

Hopefully this approach works well in other cases too.

@meg-gupta meg-gupta merged commit 3f6bfca into swiftlang:main Mar 24, 2023
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