From 6e8a8c2d7e6c5091ee5c838e8cafafa72dbfca59 Mon Sep 17 00:00:00 2001 From: Tres Popp Date: Mon, 9 Nov 2020 15:55:08 +0100 Subject: [PATCH] [mlir] Fix bug in use of rewiter for AtomicRMWOp. The legalization did not forward the listener which prevents dynamic legalization and prevents rollbacks. This handled that and then changed the associated pass to support all other std ops to support partial conversion. Previously, this lowering was failing, but due to the initial bug, the op's modifications were not reverted, and thus the pattern matching succeeded. Differential Revision: https://reviews.llvm.org/D91079 --- mlir/lib/Dialect/StandardOps/Transforms/ExpandAtomic.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mlir/lib/Dialect/StandardOps/Transforms/ExpandAtomic.cpp b/mlir/lib/Dialect/StandardOps/Transforms/ExpandAtomic.cpp index 8513880..2d04aec 100644 --- a/mlir/lib/Dialect/StandardOps/Transforms/ExpandAtomic.cpp +++ b/mlir/lib/Dialect/StandardOps/Transforms/ExpandAtomic.cpp @@ -57,7 +57,8 @@ public: auto loc = op.getLoc(); auto genericOp = rewriter.create(loc, op.memref(), op.indices()); - OpBuilder bodyBuilder = OpBuilder::atBlockEnd(genericOp.getBody()); + OpBuilder bodyBuilder = + OpBuilder::atBlockEnd(genericOp.getBody(), rewriter.getListener()); Value lhs = genericOp.getCurrentValue(); Value rhs = op.value(); @@ -76,7 +77,7 @@ struct ExpandAtomic : public ExpandAtomicBase { patterns.insert(&getContext()); ConversionTarget target(getContext()); - target.addLegalOp(); + target.addLegalDialect(); target.addDynamicallyLegalOp([](AtomicRMWOp op) { return op.kind() != AtomicRMWKind::maxf && op.kind() != AtomicRMWKind::minf; -- 2.7.4