[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 05:04:36 PDT 2024
https://github.com/paperchalice updated https://github.com/llvm/llvm-project/pull/89538
>From 60f1588fed455740727ff5086cd6c93009839bd6 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 | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h
index d701481202f8db..09f2cb2f8a209f 100644
--- a/llvm/include/llvm/IR/PassManager.h
+++ b/llvm/include/llvm/IR/PassManager.h
@@ -934,9 +934,13 @@ 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<decltype(&AnalysisT::run)>::template arg_t<0>>,
+ typename AnalysisManagerT = std::remove_reference_t<
+ typename function_traits<decltype(&AnalysisT::run)>::template arg_t<1>>,
+ typename... ExtraArgTs>
struct RequireAnalysisPass
: PassInfoMixin<RequireAnalysisPass<AnalysisT, IRUnitT, AnalysisManagerT,
ExtraArgTs...>> {
More information about the llvm-commits
mailing list