[llvm] [VPlan] Add hidden `-vplan-print-after-all` option (PR #175839)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 26 21:57:31 PST 2026


================
@@ -33,27 +33,47 @@ class VPRecipeBuilder;
 struct VFRange;
 
 LLVM_ABI_FOR_TEST extern cl::opt<bool> VerifyEachVPlan;
+LLVM_ABI_FOR_TEST extern cl::opt<bool> PrintAfterEachVPlanPass;
 LLVM_ABI_FOR_TEST extern cl::opt<bool> EnableWideActiveLaneMask;
 
 struct VPlanTransforms {
-  /// Helper to run a VPlan transform \p Transform on \p VPlan, forwarding extra
-  /// arguments to the transform. Returns the boolean returned by the transform.
-  template <typename... ArgsTy>
-  static bool runPass(bool (*Transform)(VPlan &, ArgsTy...), VPlan &Plan,
-                      typename std::remove_reference<ArgsTy>::type &...Args) {
-    bool Res = Transform(Plan, Args...);
-    if (VerifyEachVPlan)
-      verifyVPlanIsValid(Plan);
-    return Res;
-  }
   /// Helper to run a VPlan transform \p Transform on \p VPlan, forwarding extra
   /// arguments to the transform.
-  template <typename... ArgsTy>
-  static void runPass(void (*Fn)(VPlan &, ArgsTy...), VPlan &Plan,
-                      typename std::remove_reference<ArgsTy>::type &...Args) {
-    Fn(Plan, Args...);
-    if (VerifyEachVPlan)
-      verifyVPlanIsValid(Plan);
+  template <auto Transform, bool DisableVerify = false, typename... ArgsTy>
+  static auto runPass(VPlan &Plan, ArgsTy &&...Args) {
+    using ResTy = decltype(Transform(Plan, std::forward<ArgsTy>(Args)...));
+    // Needs to be directly in `runPass` and not inside a lambda below:
+    constexpr StringRef PrettyFunc{LLVM_PRETTY_FUNCTION};
----------------
lukel97 wrote:

I'm not strongly opinionated on this, but another possible idea is to make runPass a macro so you don't need the template or LLVM_PRETTY_FUNCTION?

https://github.com/llvm/llvm-project/pull/175839


More information about the llvm-commits mailing list