[llvm] [TableGen] Migrate Option Emitters to const RecordKeeper (PR #107696)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 11 06:42:56 PDT 2024


jurahul wrote:

Yeah, I have an idea. That error is emitted by `CompareOptionRecords` function that I modified. Is it possible for you to test a simple fix if I propose one here?

```
diff --git a/llvm/utils/TableGen/Common/OptEmitter.cpp b/llvm/utils/TableGen/Common/OptEmitter.cpp
index 1c91ec5b3dbc..75e32c36d4f7 100644
--- a/llvm/utils/TableGen/Common/OptEmitter.cpp
+++ b/llvm/utils/TableGen/Common/OptEmitter.cpp
@@ -41,6 +41,8 @@ static int StrCmpOptionName(const char *A, const char *B) {

 // Returns true if A is ordered before B.
 bool CompareOptionRecords(const Record *A, const Record *B) {
+  if (A == B)
+    return false;
   // Sentinel options precede all others and are only ordered by precedence.
   bool ASent = A->getValueAsDef("Kind")->getValueAsBit("Sentinel");
   bool BSent = B->getValueAsDef("Kind")->getValueAsBit("Sentinel");
```

Standard library diffs between different platforms could that the comparison function is being called with same pointers only on some patforms like Mac.

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


More information about the llvm-commits mailing list