-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[sil-optimizer] Make InstructionDeleter and related APIs to use an InstModCallback instead of a notification callback. #37016
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
[sil-optimizer] Make InstructionDeleter and related APIs to use an InstModCallback instead of a notification callback. #37016
Conversation
@swift-ci test |
/// default operation inline. What is nice about this from a perf perspective is | ||
/// that in a loop this property should predict well since you have a single | ||
/// branch that is going to go the same way everytime. | ||
class InstModCallbacks { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just moved this to work around forward declaration issues.
Build failed |
Build failed |
…stModCallback instead of a notification callback. I recently have been running into the issue that many of these APIs perform the deletion operation themselves and notify the caller it is going to delete instead of allowing the caller to specify how the instruction is deleted. This causes interesting semantic issues (see the loop in deleteInstruction I simplified) and breaks composition since many parts of the optimizer use InstModCallbacks for this purpose. To fix this, I added a notify will be deleted construct to InstModCallback. In a similar way to the rest of it, if the notify is not set, we do not call any code implying that we should have good predictable performance in loops since we will always skip the function call. I also changed InstModCallback::deleteInst() to notify before deleting so we have a default safe behavior. All previous use sites of this API do not care about being notified and the only new use sites of this API are in InstructionDeleter that perform special notification behavior (it notifies for certain sets of instructions it is going to delete before it deletes any of them). To work around this, I added a bool to deleteInst to control this behavior and defaulted to notifying. This should ensure that all other use sites still compose correctly.
35bb49c
to
7b55cbc
Compare
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as long as you comment the callback in another PR explaining the two separate use cases and the fact that InstructionDeleter (for some reason) wants to drop all refs for a bunch of instructions before actually deleting them.
Thanks will do. |
@gottesmm And I almost forgot. We shouldn't need two copies of |
@atrick I will fix that as well. |
@atrick the callback in eraseFromParentWithDebugInsts is for a notification, not the delete. That is why I did both. |
…481e36205ea258 [sil-optimizer] Fix feedback from #37016 and finish removing confusing constructors
Uh oh!
There was an error while loading. Please reload this page.