[Mlir-commits] [mlir] [mlir][transform] Improve error message of tracking listener. (PR #66987)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Thu Sep 21 00:54:22 PDT 2023


================
@@ -1444,16 +1443,20 @@ bool transform::ErrorCheckingTrackingListener::failed() const {
 }
 
 void transform::ErrorCheckingTrackingListener::notifyPayloadReplacementNotFound(
-    Operation *op, ValueRange values) {
+    Operation *op, ValueRange values, ArrayRef<Operation *> aliveUsers) {
   if (status.succeeded()) {
     status = emitSilenceableFailure(
-        getTransformOp(), "tracking listener failed to find replacement op");
+        getTransformOp(), "op was replaced but replacement was of different "
+                          "kind, invalidating alive handles");
   }
 
   status.attachNote(op->getLoc()) << "[" << errorCounter << "] replaced op";
   for (auto &&[index, value] : llvm::enumerate(values))
     status.attachNote(value.getLoc())
         << "[" << errorCounter << "] replacement value " << index;
+  for (auto &&[index, user] : llvm::enumerate(aliveUsers))
+    status.attachNote(user->getLoc())
+        << "[" << errorCounter << "] alive handle " << index;
----------------
ftynse wrote:

This feels misleading. The user is not the handle, its _operand_ is. We should capture uses (`OpOperand *`) rather than users and attach the note to the location of the value that is being used. Bonus points for giving extra information like the value being n-th result of the op (values have the location of the defining op so we cannot otherwise differentiate between them).

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


More information about the Mlir-commits mailing list