[llvm] [CodeGen][GC] Skip function without GC in `GCLoweringPass` (PR #84421)

via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 7 18:14:33 PST 2024


https://github.com/paperchalice created https://github.com/llvm/llvm-project/pull/84421

None

>From e1668c840819c5ff2ebe28424bcd54a9a2abc484 Mon Sep 17 00:00:00 2001
From: PaperChalice <liujunchang97 at outlook.com>
Date: Fri, 8 Mar 2024 10:14:00 +0800
Subject: [PATCH] [CodeGen][GC] Skip function without GC in `GCLoweringPass`

---
 llvm/lib/CodeGen/GCRootLowering.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/llvm/lib/CodeGen/GCRootLowering.cpp b/llvm/lib/CodeGen/GCRootLowering.cpp
index 894ab9a0486a7b..0d82f2bab8960b 100644
--- a/llvm/lib/CodeGen/GCRootLowering.cpp
+++ b/llvm/lib/CodeGen/GCRootLowering.cpp
@@ -81,6 +81,9 @@ class GCMachineCodeAnalysis : public MachineFunctionPass {
 
 PreservedAnalyses GCLoweringPass::run(Function &F,
                                       FunctionAnalysisManager &FAM) {
+  if (!F.hasGC())
+    return PreservedAnalyses::all();
+
   auto &Info = FAM.getResult<GCFunctionAnalysis>(F);
 
   bool Changed = DoLowering(F, Info.getStrategy());



More information about the llvm-commits mailing list