Issue |
146940
|
Summary |
[MLIR] `getRegisteredOperationsByDialect` comparator lambdas return int instead of bool, causing incorrect operation filtering
|
Labels |
mlir
|
Assignees |
|
Reporter |
rpavlovicTT
|
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();
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs