[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
Fri Aug 28 22:59:32 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:
>Can you clarify what you mean by that?
This is how I implemented the new empty check in `doFind`:
```c++
if (NumBuckets == 0) return nullptr;
if (getNumEntries() == 0) return nullptr; // new: runs every time
// ... hash the key, probe the buckets
```
This adds a load of `NumEntries` and a subsequent branch to every call to `doFind`. The cost becomes visible when the early-out is combined with this PR: -0.190%, against -0.290% for this PR alone.
| variant | mlir-opt | clang self-host |
|---|---:|---:|
| this PR (guard in `Dialect`) | **-0.290%** | 0.00% (MLIR not linked into clang) |
| `doFind` early-out | -0.115% | **+0.063%** |
| + `LLVM_UNLIKELY` | -0.144% | **-0.042%** |
| both together | -0.190% | -0.042% |
https://github.com/llvm/llvm-project/pull/219545
More information about the Mlir-commits
mailing list