[Mlir-commits] [mlir] [mlir] Skip the promised-interface lookup for an emptied dialect set (NFC) (PR #219545)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sat Aug 29 02:22:55 PDT 2026


================
@@ -228,6 +228,9 @@ class Dialect {
   void handleUseOfUndefinedPromisedInterface(TypeID interfaceRequestorID,
                                              TypeID interfaceID,
                                              StringRef interfaceName = "") {
+    // Most dialects promise nothing; skip hashing a key and probing the set.
+    if (unresolvedPromisedInterfaces.empty())
+      return;
     if (unresolvedPromisedInterfaces.count(
----------------
khaki3 wrote:

>Why check `NumBuckets`?

That one is pre-existing and necessary to avoid the underflow of `Mask`.

https://github.com/llvm/llvm-project/blob/48d00593530dbfd90c4fdb027ae260868f39925f/llvm/include/llvm/ADT/DenseMap.h#L723-L728

A check in `doFind` runs on every lookup. With `LLVM_UNLIKELY` it does help (-0.042% clang, -0.144% mlir-opt), but it overlaps this PR, which checks one hot spot and gets -0.290%.

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


More information about the Mlir-commits mailing list