diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -841,6 +841,19 @@ return true; } + /// Setup an analysis pass previously registered with the manager. + /// + /// The parameter is a callable taking a pointer to \p PassT and returning bool. + /// This allows passing in a lambda to modify the analysis behavior after + /// it has been registered. + template + bool setupAnalysis(CallableT Setup) { + auto &PassPtr = AnalysisPasses[PassT::ID()]; + if (PassPtr) + return Setup(PassPtr.get()); + return false; + } + /// Invalidate a specific analysis pass for an IR module. /// /// Note that the analysis result can disregard invalidation, if it determines