Finding uses of a value and replacing them with a new one is a common method. I have not seen an safe and easy shortcut that does that. This revision attempts to address that by intoroducing replaceUsesOfWith to RewriterBase.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/IR/PatternMatch.cpp | ||
---|---|---|
315–317 | Why is this collecting all of the uses into a vector? |
mlir/lib/IR/PatternMatch.cpp | ||
---|---|---|
315–317 | My motivation of this change comes from D138029. Shortly, the old code looked like this. getUsers iterates on actual users in this situation. It is incorrect because I am modifying uses while iterating. Ofc, I am happy to change if there is better way. for (Operation *user : llvm::make_early_inc_range(from.getUsers())) rewriter.updateRootInPlace(user, [&]() { user->replaceUsesOfWith(from, to); }); |
mlir/lib/IR/PatternMatch.cpp | ||
---|---|---|
315–317 | Have you tried an early inc range of getUses? |
mlir/include/mlir/IR/PatternMatch.h | ||
---|---|---|
505 | Note that using this instead of from.replaceUsesOfWith(to) will mark every modified users and notify the listener. |
Note that using this instead of from.replaceUsesOfWith(to) will mark every modified users and notify the listener.