-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang] Add regalloc PBQP for all targets in clang #166645
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
base: main
Are you sure you want to change the base?
[clang] Add regalloc PBQP for all targets in clang #166645
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
@llvm/pr-subscribers-clang Author: Ivan Shumakov (Zararest) ChangesThere is an issue with using PBQP register allocator in clang that doesn't have AArch64 target: This change links PBQP regalloc to all LLVM targets. Full diff: https://github.com/llvm/llvm-project/pull/166645.diff 4 Files Affected:
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);
}
|
|
@lhames could you, please, review these changes or give a hint who I should tag |
|
@Zararest -- seems reasonable to me. I believe that we used to offer it on all platforms. Out of interest: Did you check what this does to the size of the clang binary? |
|
Here are sizes of a clang binary before and after current commit: |
lhames
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me. Thanks @Zararest!
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.