[clang] [llvm] [clang] Add regalloc PBQP for all targets in clang (PR #166645)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 5 13:31:42 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Ivan Shumakov (Zararest)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/166645.diff
4 Files Affected:
- (added) clang/test/CodeGen/PBQP-regalloc-all-targets.c (+8)
- (modified) llvm/include/llvm/InitializePasses.h (+1)
- (modified) llvm/lib/CodeGen/CodeGen.cpp (+1)
- (modified) llvm/lib/CodeGen/RegAllocPBQP.cpp (+3)
``````````diff
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);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/166645
More information about the cfe-commits
mailing list