diff --git a/llvm/include/llvm/PassSupport.h b/llvm/include/llvm/PassSupport.h index 2806d9b52b0b9..b0897a6be37d1 100644 --- a/llvm/include/llvm/PassSupport.h +++ b/llvm/include/llvm/PassSupport.h @@ -64,20 +64,13 @@ class Pass; INITIALIZE_PASS_WITH_OPTIONS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \ INITIALIZE_PASS_END(PassName, Arg, Name, Cfg, Analysis) -template < - class PassName, - std::enable_if_t{}, bool> = true> -Pass *callDefaultCtor() { - return new PassName(); -} - -template < - class PassName, - std::enable_if_t{}, bool> = true> -Pass *callDefaultCtor() { - // Some codegen passes should only be testable via - // `llc -{start|stop}-{before|after}=`, not via `opt -`. - report_fatal_error("target-specific codegen-only pass"); +template Pass *callDefaultCtor() { + if constexpr (std::is_default_constructible_v) + return new PassName(); + else + // Some codegen passes should only be testable via + // `llc -{start|stop}-{before|after}=`, not via `opt -`. + report_fatal_error("target-specific codegen-only pass"); } //===---------------------------------------------------------------------------