[llvm] [Pass] Use `function_traits` to infer `IRUnitT` and `AnalysisT` in `RequireAnalysisPass ` (PR #89538)

via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 21 04:20:29 PDT 2024


https://github.com/paperchalice updated https://github.com/llvm/llvm-project/pull/89538

>From 64b26ded33fc7a9583ab84c49d62746bed93c179 Mon Sep 17 00:00:00 2001
From: PaperChalice <liujunchang97 at outlook.com>
Date: Sun, 21 Apr 2024 19:20:12 +0800
Subject: [PATCH] [Pass] Use function_traits to infer `IRUnitT` and `AnalysisT`
 in `RequireAnalysisPass`

---
 llvm/include/llvm/IR/PassManager.h | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h
index d701481202f8db..f9eb56da17a597 100644
--- a/llvm/include/llvm/IR/PassManager.h
+++ b/llvm/include/llvm/IR/PassManager.h
@@ -934,12 +934,15 @@ createModuleToFunctionPassAdaptor(FunctionPassT &&Pass,
 ///
 /// Specific patterns of run-method extra arguments and analysis manager extra
 /// arguments will have to be defined as appropriate specializations.
-template <typename AnalysisT, typename IRUnitT,
-          typename AnalysisManagerT = AnalysisManager<IRUnitT>,
-          typename... ExtraArgTs>
+template <
+    typename AnalysisT,
+    typename IRUnitT = std::remove_reference_t<
+        typename function_traits<typename AnalysisT::run>::template arg_t<0>>,
+    typename AnalysisManagerT = std::remove_reference_t<
+        typename function_traits<typename AnalysisT::run>::template arg_t<1>>,
+    typename... ExtraArgTs>
 struct RequireAnalysisPass
-    : PassInfoMixin<RequireAnalysisPass<AnalysisT, IRUnitT, AnalysisManagerT,
-                                        ExtraArgTs...>> {
+    : PassInfoMixin<RequireAnalysisPass<AnalysisT, ExtraArgTs...>> {
   /// Run this pass over some unit of IR.
   ///
   /// This pass can be run over any unit of IR and use any analysis manager



More information about the llvm-commits mailing list