[llvm] [TableGen] Make ClassInfo sorting deterministic in AsmMatcherEmitter (PR #172894)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 18 21:04:14 PST 2025
================
@@ -380,11 +380,13 @@ struct ClassInfo {
}
// FIXME: We should be able to just return false here, as we only need a
- // partial order (we use stable sorts, so this is deterministic) and the
- // name of a class shouldn't be significant. However, some of the backends
- // accidentally rely on this behaviour, so it will have to stay like this
- // until they are fixed.
- return ValueName < RHS.ValueName;
+ // partial order and the name of a class shouldn't be significant.
+ // However, some of the backends accidentally rely on this behaviour.
+ // We sort by ValueName and use Name as a tie-breaker to ensure
+ // deterministic output for binary reproducibility.
+ if (ValueName != RHS.ValueName)
----------------
windsunil wrote:
Thanks for the suggestion. Using std::tie() does make the comparison cleaner — I’ll update the code accordingly.
https://github.com/llvm/llvm-project/pull/172894
More information about the llvm-commits
mailing list