[Mlir-commits] [mlir] [mlir][Transforms] Improve `replaceOpWithMultiple` API (PR #132608)

Markus Böck llvmlistbot at llvm.org
Wed Mar 26 01:21:38 PDT 2025


https://github.com/zero9178 commented:

Making things not copy in the ideal case is slightly more involved as it affects all functions that are sinks: functions that take data from parameters and store them directly into internal datastructures, including transitively and must be able to move them. 

This sadly disqualifies using `ArrayRef` as parameter as it always returns a `const` reference, which will never call the move constructor. The good news is that `SmallVector` has a move constructor from `SmallVectorImpl`, i.e. we do not need `SmallVector<Value, 1>`. 

I prototyped a solution in https://github.com/zero9178/llvm-project/commit/b30cdb12781fa603eb8e3803449f7f1530b7439d but it requires a few more changes including in ADT. 
It makes all the sinks either have two overloads: `SmallVector<SmallVector<Value>>&&` for when the user does a `std::move` or construct a copy to be moved. This is not ideal compared to e.g. having two overloads of every funciton (one for moving, one without), but an improvement nevertheless.

https://github.com/llvm/llvm-project/pull/132608


More information about the Mlir-commits mailing list