This is an archive of the discontinued LLVM Phabricator instance.

[mlir][NFC] Add helper for common pattern of replaceAllUsesExcept
ClosedPublic

Authored by silvas on May 12 2021, 3:07 PM.

Details

Summary

This covers the extremely common case of replacing all uses of a Value
with a new op that is itself a user of the original Value.

This should also be a little bit more efficient than the
SmallPtrSet<Operation *, 1>{op} idiom that was being used before.

Diff Detail

Event Timeline

silvas created this revision.May 12 2021, 3:07 PM
silvas requested review of this revision.May 12 2021, 3:07 PM
rriddle accepted this revision.May 12 2021, 5:31 PM
This revision is now accepted and ready to land.May 12 2021, 5:31 PM
bondhugula accepted this revision.May 12 2021, 10:00 PM
bondhugula added a subscriber: bondhugula.

Nice.

mlir/lib/IR/Value.cpp
77

Nit: auto -> OpOperand
(should still fit in one line)

silvas added inline comments.May 13 2021, 12:35 PM
mlir/lib/IR/Value.cpp
77

That would be good but auto is consistent with the other replaceAllUsesExcept functions

silvas added inline comments.May 13 2021, 12:37 PM
mlir/lib/IR/Value.cpp
77

Sorry, I see it is ambiguous with replaceUsesWithIf as well. Will change both replaceAllUsesExcept to OpOperand