[Mlir-commits] [mlir] [mlir][Transforms][NFC] Improve listener layering in dialect conversion (PR #80825)

Matthias Springer llvmlistbot at llvm.org
Wed Feb 7 00:24:30 PST 2024


================
@@ -582,7 +582,8 @@ class AwaitOpLoweringBase : public OpConversionPattern<AwaitType> {
     // Inside regular functions we use the blocking wait operation to wait for
     // the async object (token, value or group) to become available.
     if (!isInCoroutine) {
-      ImplicitLocOpBuilder builder(loc, op, &rewriter);
+      ImplicitLocOpBuilder builder(loc, rewriter);
+      builder.setInsertionPoint(op);
----------------
matthias-springer wrote:

```c++
ImplicitLocOpBuilder builder(loc, op, &rewriter);
```
The above constructor sets the insertion point before `op` and attaches `&rewriter` as a listener.

After this commit, `ConversionPatternRewriter` no longer inherits from `Listener`, but we must still attach the same listener that is attached to `rewriter`. (`rewriter` used to have itself attached as a listener.) That's what `ImplicitLocOpBuilder builder(loc, rewriter);` does. There is no constructor that takes an existing `OpBuilder` (or subclass thereof) and op (to set the insertion point), so I have to manually set the insertion point with `setInsertionPoint`.


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


More information about the Mlir-commits mailing list