Skip to content

TableGen: Sort RuntimeLibcallImpls secondarily by enum names #150728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Jul 26, 2025

Extracted from #150192, this hopefully fixes occasional EXPENSIVE_CHECKS
failures.

@arsenm arsenm added the tablegen label Jul 26, 2025 — with Graphite App
Copy link
Contributor Author

arsenm commented Jul 26, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arsenm arsenm marked this pull request as ready for review July 26, 2025 01:02
@llvmbot
Copy link
Member

llvmbot commented Jul 26, 2025

@llvm/pr-subscribers-tablegen

Author: Matt Arsenault (arsenm)

Changes

Extracted from #150192, this hopefully fixes occasional EXPENSIVE_CHECKS
failures.


Full diff: https://github.com/llvm/llvm-project/pull/150728.diff

2 Files Affected:

  • (modified) llvm/test/TableGen/RuntimeLibcallEmitter.td (+3-3)
  • (modified) llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp (+4-5)
diff --git a/llvm/test/TableGen/RuntimeLibcallEmitter.td b/llvm/test/TableGen/RuntimeLibcallEmitter.td
index 579e3c7dd62ab..783a861cfe756 100644
--- a/llvm/test/TableGen/RuntimeLibcallEmitter.td
+++ b/llvm/test/TableGen/RuntimeLibcallEmitter.td
@@ -95,8 +95,8 @@ def BlahLibrary : SystemRuntimeLibrary<isBlahArch, (add calloc, LibraryWithCondi
 // CHECK-NEXT:  __lshrdi3 = 4, // __lshrdi3
 // CHECK-NEXT:  bzero = 5, // bzero
 // CHECK-NEXT:  calloc = 6, // calloc
-// CHECK-NEXT:  sqrtl_f80 = 7, // sqrtl
-// CHECK-NEXT:  sqrtl_f128 = 8, // sqrtl
+// CHECK-NEXT:  sqrtl_f128 = 7, // sqrtl
+// CHECK-NEXT:  sqrtl_f80 = 8, // sqrtl
 // CHECK-NEXT:  NumLibcallImpls = 9
 // CHECK-NEXT: };
 // CHECK-NEXT: } // End namespace RTLIB
@@ -157,8 +157,8 @@ def BlahLibrary : SystemRuntimeLibrary<isBlahArch, (add calloc, LibraryWithCondi
 // CHECK-NEXT: RTLIB::SRL_I64, // RTLIB::__lshrdi3
 // CHECK-NEXT: RTLIB::BZERO, // RTLIB::bzero
 // CHECK-NEXT: RTLIB::CALLOC, // RTLIB::calloc
-// CHECK-NEXT: RTLIB::SQRT_F80, // RTLIB::sqrtl_f80
 // CHECK-NEXT: RTLIB::SQRT_F128, // RTLIB::sqrtl_f128
+// CHECK-NEXT: RTLIB::SQRT_F80, // RTLIB::sqrtl_f80
 // CHECK-NEXT: };
 
 
diff --git a/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp b/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
index 7f90d6b4fdacc..a280604ade2e8 100644
--- a/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
+++ b/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
@@ -242,11 +242,10 @@ class RuntimeLibcallEmitter {
     SmallVector<const Record *, 1024> AllRuntimeLibcallImpls(
         AllRuntimeLibcallImplsRaw);
 
-    // Sort by libcall impl name, not the enum name. This keeps the order
-    // suitable for using the name table for libcall recognition binary search.
-    llvm::sort(AllRuntimeLibcallImpls, [](const Record *A, const Record *B) {
-      return A->getValueAsString("LibCallFuncName") <
-             B->getValueAsString("LibCallFuncName");
+    // Sort by libcall impl name and secondarily by the enum name.
+    sort(AllRuntimeLibcallImpls, [](const Record *A, const Record *B) {
+      return std::pair(A->getValueAsString("LibCallFuncName"), A->getName()) <
+             std::pair(B->getValueAsString("LibCallFuncName"), B->getName());
     });
 
     RuntimeLibcallImplDefList.reserve(AllRuntimeLibcallImpls.size());

@arsenm arsenm force-pushed the users/arsenm/tablegen/sort-runtime-libcall-impls-enum-name branch from 0d55e94 to f312e74 Compare July 26, 2025 01:43
Copy link
Contributor Author

arsenm commented Jul 26, 2025

Merge activity

  • Jul 26, 1:44 AM UTC: Graphite rebased this pull request as part of a merge.
  • Jul 26, 1:51 AM UTC: Graphite rebased this pull request as part of a merge.
  • Jul 26, 1:56 AM UTC: Graphite rebased this pull request as part of a merge.
  • Jul 26, 2:21 AM UTC: Graphite rebased this pull request as part of a merge.

@arsenm arsenm force-pushed the users/arsenm/tablegen/sort-runtime-libcall-impls-enum-name branch from f312e74 to 2ffcdfe Compare July 26, 2025 01:50
@arsenm
Copy link
Contributor Author

arsenm commented Jul 26, 2025

Merge activity

  • Jul 26, 1:44 AM UTC: Graphite rebased this pull request as part of a merge.

I think all the checks passed, and then it started the whole process over? Is it trying to redo tests if anything else already merged to main?

@arsenm arsenm force-pushed the users/arsenm/tablegen/sort-runtime-libcall-impls-enum-name branch from 2ffcdfe to b279156 Compare July 26, 2025 01:55
Extracted from #150192, this hopefully fixes occasional EXPENSIVE_CHECKS
failures.
@arsenm arsenm force-pushed the users/arsenm/tablegen/sort-runtime-libcall-impls-enum-name branch from b279156 to e65c241 Compare July 26, 2025 02:21
@arsenm arsenm merged commit bd7db75 into main Jul 26, 2025
7 of 9 checks passed
@arsenm arsenm deleted the users/arsenm/tablegen/sort-runtime-libcall-impls-enum-name branch July 26, 2025 02:23
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jul 28, 2025
…0728)

Extracted from llvm#150192, this hopefully fixes occasional EXPENSIVE_CHECKS
failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants