[Mlir-commits] [mlir] [mlir][TableGen][NFC] Emit interface traits after all interfaces (PR #147699)

Andrei Golubev llvmlistbot at llvm.org
Wed Jul 9 04:22:30 PDT 2025


================
@@ -619,10 +638,15 @@ bool InterfaceGenerator::emitInterfaceDecls() {
   llvm::sort(sortedDefs, [](const Record *lhs, const Record *rhs) {
     return lhs->getID() < rhs->getID();
   });
+  for (const Record *def : sortedDefs)
+    forwardDeclareInterface(Interface(def));
   for (const Record *def : sortedDefs)
     emitInterfaceDecl(Interface(def));
   for (const Record *def : sortedDefs)
     emitModelMethodsDef(Interface(def));
+  for (const Record *def : sortedDefs)
+    emitInterfaceTraitDecl(Interface(def));
----------------
andrey-golubev wrote:

fyi: `Interface` ctor can be rather expensive (it has a vector of base interfaces that it populates + vector of methods).
As we re-create the objects *4* times here, does it make sense to refactor? (I failed to do it immediately so it'd probably go into a separate patch).

FWIW tablegen is part of the build system so if it is slow, the whole build is slow.

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


More information about the Mlir-commits mailing list