Skip to content

[inst-opt-utils] If InstModCallback::setUseValueFunc isn't set, just call RAUW directly rather than calling the default setUseValueFunc. #37006

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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/swift/SILOptimizer/Utils/InstOptUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,13 @@ class InstModCallbacks {
void replaceValueUsesWith(SILValue oldValue, SILValue newValue) {
wereAnyCallbacksInvoked = true;

// If setUseValueFunc is not set, just call RAUW directly. RAUW in this case
// is equivalent to what we do below. We just enable better
// performance. This ensures that the default InstModCallback is really
// fast.
if (!setUseValueFunc)
return oldValue->replaceAllUsesWith(newValue);

while (!oldValue->use_empty()) {
auto *use = *oldValue->use_begin();
setUseValue(use, newValue);
Expand Down