The implementation of MLIRContext::getRegisteredOperationsByDialect uses std::lower_bound and std::upper_bound with comparator lambdas that return the result of StringRef::compare() directly (an int), instead of a boolean. Since these standard algorithms require comparators returning bool representing a strict weak ordering, returning an int causes undefined behavior and leads to incorrect or empty results when filtering operations by dialect.
Proposed fix:
// lower_bound comparator
[](const RegisteredOperationName &lhs, StringRef dialectName) {
return lhs.getDialect().getNamespace() < dialectName;
}
// upper_bound comparator
[](StringRef dialectName, const RegisteredOperationName &rhs) {
return dialectName < rhs.getDialect().getNamespace();
}