From 0115d5c951232838ce3aad48d9be41d4d8eea1c1 Mon Sep 17 00:00:00 2001 From: Rahul Joshi Date: Wed, 11 Sep 2024 06:43:59 -0700 Subject: [PATCH] [TableGen] Fix MacOS failure in Option Emitter. Handle the case of same pointer used as both inputs to the `CompareOptionRecords`, to avoid emitting errors for equivalent options. --- llvm/utils/TableGen/Common/OptEmitter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/llvm/utils/TableGen/Common/OptEmitter.cpp b/llvm/utils/TableGen/Common/OptEmitter.cpp index 1c91ec5b3dbc4..75e32c36d4f72 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");