[Mlir-commits] [mlir] [mlir][tblgen] Error on unsubstituted $_self in op trait predicates (PR #227263)

Mehdi Amini llvmlistbot at llvm.org
Tue Sep 29 03:52:31 PDT 2026


================
@@ -3764,10 +3764,20 @@ void OpEmitter::genVerifier() {
 
   for (auto &trait : op.getTraits()) {
     if (auto *t = dyn_cast<tblgen::PredTrait>(&trait)) {
+      // Trait predicates expand against the whole operation, so $_self is not
+      // substituted here; catch it and report at the ODS level instead
+      std::string pred = tgfmt(t->getPredTemplate(), &verifyCtx);
+      if (StringRef(pred).contains("<no-subst-found>"))
+        PrintFatalError(op.getLoc(),
+                        "trait '" + t->getSummary() + "' on operation '" +
+                            op.getOperationName() +
+                            "' uses $_self in its predicate, but $_self is "
----------------
joker-eph wrote:

I don't quite get what is special about $_self here?  You can use many other non-defined expansion can't you?

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


More information about the Mlir-commits mailing list