Skip to content

Commit db8a119

Browse files
[mlir][ArmSME] Fix invalid rewriter API usage (#76123)
When operations are modified in-place, the rewriter must be notified. This commit fixes `mlir/test/Conversion/ArmSMEToLLVM/unsupported.mlir`, `mlir/test/Dialect/ArmSME/tile-zero-masks.mlir` and `mlir/test/Dialect/ArmSME/vector-ops-to-llvm.mlir` when running with `MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS` enabled.
1 parent 2203a4e commit db8a119

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,10 @@ struct AssignTileIDsPattern
223223
if (failed(tileId))
224224
return tileOp.emitError("ran out of SME virtual tiles!");
225225

226-
func->setDiscardableAttr(kTilesInUseAttr,
227-
rewriter.getI32IntegerAttr((unsigned)tilesInUse));
226+
rewriter.updateRootInPlace(func, [&]() {
227+
func->setDiscardableAttr(
228+
kTilesInUseAttr, rewriter.getI32IntegerAttr((unsigned)tilesInUse));
229+
});
228230

229231
// Find all the ops that (transitively) depend on this tile.
230232
SetVector<Operation *> dependantOps;
@@ -245,14 +247,15 @@ struct AssignTileIDsPattern
245247
// scf.if, and moving the contents of %tileA or %tileB to result tile (based
246248
// on the %some_cond).
247249
auto tileIDAttr = rewriter.getI32IntegerAttr(*tileId);
248-
tileOp.setTileId(tileIDAttr);
250+
rewriter.updateRootInPlace(tileOp, [&]() { tileOp.setTileId(tileIDAttr); });
249251
for (auto *op : dependantOps) {
250252
if (auto tileOp = llvm::dyn_cast<ArmSMETileOpInterface>(op)) {
251253
auto currentTileId = tileOp.getTileId();
252254
if (currentTileId && unsigned(currentTileId.getInt()) != tileId)
253255
return tileOp.emitOpError(
254256
"already assigned different SME virtual tile!");
255-
tileOp.setTileId(tileIDAttr);
257+
rewriter.updateRootInPlace(tileOp,
258+
[&]() { tileOp.setTileId(tileIDAttr); });
256259
}
257260
}
258261

0 commit comments

Comments
 (0)