[clang] [llvm] [clang] Add regalloc PBQP for all targets in clang (PR #166645)
Ivan Shumakov via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 5 13:30:47 PST 2025
https://github.com/Zararest created https://github.com/llvm/llvm-project/pull/166645
There is an issue with using PBQP register allocator in clang that doesn't have AArch64 target:
https://groups.google.com/g/llvm-dev/c/ZIvatINBENo
This change links PBQP regalloc to all LLVM targets.
>From aea70e2df65119377e9d3f732b1850c2ec554618 Mon Sep 17 00:00:00 2001
From: Ivan Shumakov <iishumakov at gmail.com>
Date: Thu, 6 Nov 2025 00:19:55 +0300
Subject: [PATCH] [clang] Add regalloc PBQP for all targets in clang
---
clang/test/CodeGen/PBQP-regalloc-all-targets.c | 8 ++++++++
llvm/include/llvm/InitializePasses.h | 1 +
llvm/lib/CodeGen/CodeGen.cpp | 1 +
llvm/lib/CodeGen/RegAllocPBQP.cpp | 3 +++
4 files changed, 13 insertions(+)
create mode 100644 clang/test/CodeGen/PBQP-regalloc-all-targets.c
diff --git a/clang/test/CodeGen/PBQP-regalloc-all-targets.c b/clang/test/CodeGen/PBQP-regalloc-all-targets.c
new file mode 100644
index 0000000000000..c316423f4886c
--- /dev/null
+++ b/clang/test/CodeGen/PBQP-regalloc-all-targets.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -triple x86_64 -O2 \
+// RUN: -mllvm -regalloc=pbqp \
+// RUN: -mllvm --print-changed -S |& FileCheck %s
+// CHECK: IR Dump After PBQP Register Allocator (regallocpbqp) on foo
+
+extern int foo(int a, int b) {
+ return a + b;
+}
\ No newline at end of file
diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index 88272f053c114..858fd256f8c6e 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -269,6 +269,7 @@ LLVM_ABI void initializeReassociateLegacyPassPass(PassRegistry &);
LLVM_ABI void
initializeRegAllocEvictionAdvisorAnalysisLegacyPass(PassRegistry &);
LLVM_ABI void initializeRegAllocFastPass(PassRegistry &);
+LLVM_ABI void initializeRegAllocPBQPPass(PassRegistry &);
LLVM_ABI void
initializeRegAllocPriorityAdvisorAnalysisLegacyPass(PassRegistry &);
LLVM_ABI void initializeRegAllocScoringPass(PassRegistry &);
diff --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp
index 9e0cb3bf44906..df6a12324887b 100644
--- a/llvm/lib/CodeGen/CodeGen.cpp
+++ b/llvm/lib/CodeGen/CodeGen.cpp
@@ -114,6 +114,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
initializeRAGreedyLegacyPass(Registry);
initializeReachingDefInfoWrapperPassPass(Registry);
initializeRegAllocFastPass(Registry);
+ initializeRegAllocPBQPPass(Registry);
initializeRegUsageInfoCollectorLegacyPass(Registry);
initializeRegUsageInfoPropagationLegacyPass(Registry);
initializeRegisterCoalescerLegacyPass(Registry);
diff --git a/llvm/lib/CodeGen/RegAllocPBQP.cpp b/llvm/lib/CodeGen/RegAllocPBQP.cpp
index 048cd21db062d..a4d859650300c 100644
--- a/llvm/lib/CodeGen/RegAllocPBQP.cpp
+++ b/llvm/lib/CodeGen/RegAllocPBQP.cpp
@@ -946,6 +946,9 @@ void PBQP::RegAlloc::PBQPRAGraph::printDot(raw_ostream &OS) const {
OS << "}\n";
}
+INITIALIZE_PASS(RegAllocPBQP, "regallocpbqp", "PBQP Register Allocator", false,
+ false)
+
FunctionPass *llvm::createPBQPRegisterAllocator(char *customPassID) {
return new RegAllocPBQP(customPassID);
}
More information about the llvm-commits
mailing list