diff --git a/llvm/include/llvm/IR/PassInstrumentation.h b/llvm/include/llvm/IR/PassInstrumentation.h --- a/llvm/include/llvm/IR/PassInstrumentation.h +++ b/llvm/include/llvm/IR/PassInstrumentation.h @@ -35,7 +35,7 @@ /// executed and IRUnit it works on. There can be different schemes of /// providing names in future, currently it is just a name() of the pass. /// -/// - PassInstrumentation wraps address of IRUnit into llvm::Any and passes +/// - PassInstrumentation wraps address of IRUnit into std::any and passes /// control to all the registered callbacks. Note that we specifically wrap /// 'const IRUnitT*' so as to avoid any accidental changes to IR in /// instrumenting callbacks. @@ -49,10 +49,10 @@ #ifndef LLVM_IR_PASSINSTRUMENTATION_H #define LLVM_IR_PASSINSTRUMENTATION_H -#include "llvm/ADT/Any.h" #include "llvm/ADT/FunctionExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" +#include #include #include @@ -66,7 +66,7 @@ class PassInstrumentationCallbacks { public: // Before/After callbacks accept IRUnits whenever appropriate, so they need - // to take them as constant pointers, wrapped with llvm::Any. + // to take them as constant pointers, wrapped with std::any. // For the case when IRUnit has been invalidated there is a different // callback to use - AfterPassInvalidated. // We call all BeforePassFuncs to determine if a pass should run or not. @@ -75,14 +75,14 @@ // already invalidated IRUnit is unsafe. There are ways to handle invalidated // IRUnits in a safe way, and we might pursue that as soon as there is a // useful instrumentation that needs it. - using BeforePassFunc = bool(StringRef, Any); - using BeforeSkippedPassFunc = void(StringRef, Any); - using BeforeNonSkippedPassFunc = void(StringRef, Any); - using AfterPassFunc = void(StringRef, Any, const PreservedAnalyses &); + using BeforePassFunc = bool(StringRef, std::any); + using BeforeSkippedPassFunc = void(StringRef, std::any); + using BeforeNonSkippedPassFunc = void(StringRef, std::any); + using AfterPassFunc = void(StringRef, std::any, const PreservedAnalyses &); using AfterPassInvalidatedFunc = void(StringRef, const PreservedAnalyses &); - using BeforeAnalysisFunc = void(StringRef, Any); - using AfterAnalysisFunc = void(StringRef, Any); - using AnalysisInvalidatedFunc = void(StringRef, Any); + using BeforeAnalysisFunc = void(StringRef, std::any); + using AfterAnalysisFunc = void(StringRef, std::any); + using AnalysisInvalidatedFunc = void(StringRef, std::any); using AnalysesClearedFunc = void(StringRef); public: @@ -233,15 +233,15 @@ bool ShouldRun = true; if (!isRequired(Pass)) { for (auto &C : Callbacks->ShouldRunOptionalPassCallbacks) - ShouldRun &= C(Pass.name(), llvm::Any(&IR)); + ShouldRun &= C(Pass.name(), std::any(&IR)); } if (ShouldRun) { for (auto &C : Callbacks->BeforeNonSkippedPassCallbacks) - C(Pass.name(), llvm::Any(&IR)); + C(Pass.name(), std::any(&IR)); } else { for (auto &C : Callbacks->BeforeSkippedPassCallbacks) - C(Pass.name(), llvm::Any(&IR)); + C(Pass.name(), std::any(&IR)); } return ShouldRun; @@ -255,7 +255,7 @@ const PreservedAnalyses &PA) const { if (Callbacks) for (auto &C : Callbacks->AfterPassCallbacks) - C(Pass.name(), llvm::Any(&IR), PA); + C(Pass.name(), std::any(&IR), PA); } /// AfterPassInvalidated instrumentation point - takes \p Pass instance @@ -275,7 +275,7 @@ void runBeforeAnalysis(const PassT &Analysis, const IRUnitT &IR) const { if (Callbacks) for (auto &C : Callbacks->BeforeAnalysisCallbacks) - C(Analysis.name(), llvm::Any(&IR)); + C(Analysis.name(), std::any(&IR)); } /// AfterAnalysis instrumentation point - takes \p Analysis instance @@ -284,7 +284,7 @@ void runAfterAnalysis(const PassT &Analysis, const IRUnitT &IR) const { if (Callbacks) for (auto &C : Callbacks->AfterAnalysisCallbacks) - C(Analysis.name(), llvm::Any(&IR)); + C(Analysis.name(), std::any(&IR)); } /// AnalysisInvalidated instrumentation point - takes \p Analysis instance @@ -294,7 +294,7 @@ void runAnalysisInvalidated(const PassT &Analysis, const IRUnitT &IR) const { if (Callbacks) for (auto &C : Callbacks->AnalysisInvalidatedCallbacks) - C(Analysis.name(), llvm::Any(&IR)); + C(Analysis.name(), std::any(&IR)); } /// AnalysesCleared instrumentation point - takes name of IR that analyses diff --git a/llvm/include/llvm/Passes/StandardInstrumentations.h b/llvm/include/llvm/Passes/StandardInstrumentations.h --- a/llvm/include/llvm/Passes/StandardInstrumentations.h +++ b/llvm/include/llvm/Passes/StandardInstrumentations.h @@ -46,8 +46,8 @@ void registerCallbacks(PassInstrumentationCallbacks &PIC); private: - void printBeforePass(StringRef PassID, Any IR); - void printAfterPass(StringRef PassID, Any IR); + void printBeforePass(StringRef PassID, std::any IR); + void printAfterPass(StringRef PassID, std::any IR); void printAfterPassInvalidated(StringRef PassID); bool shouldPrintBeforePass(StringRef PassID); @@ -55,7 +55,7 @@ using PrintModuleDesc = std::tuple; - void pushModuleDesc(StringRef PassID, Any IR); + void pushModuleDesc(StringRef PassID, std::any IR); PrintModuleDesc popModuleDesc(StringRef PassID); PassInstrumentationCallbacks *PIC; @@ -71,7 +71,7 @@ private: bool DebugLogging; - bool shouldRun(StringRef PassID, Any IR); + bool shouldRun(StringRef PassID, std::any IR); }; class OptPassGateInstrumentation { @@ -79,7 +79,7 @@ bool HasWrittenIR = false; public: OptPassGateInstrumentation(LLVMContext &Context) : Context(Context) {} - bool shouldRun(StringRef PassName, Any IR); + bool shouldRun(StringRef PassName, std::any IR); void registerCallbacks(PassInstrumentationCallbacks &PIC); }; @@ -181,9 +181,9 @@ // Determine if this pass/IR is interesting and if so, save the IR // otherwise it is left on the stack without data. - void saveIRBeforePass(Any IR, StringRef PassID, StringRef PassName); + void saveIRBeforePass(std::any IR, StringRef PassID, StringRef PassName); // Compare the IR from before the pass after the pass. - void handleIRAfterPass(Any IR, StringRef PassID, StringRef PassName); + void handleIRAfterPass(std::any IR, StringRef PassID, StringRef PassName); // Handle the situation where a pass is invalidated. void handleInvalidatedPass(StringRef PassID); @@ -192,16 +192,16 @@ void registerRequiredCallbacks(PassInstrumentationCallbacks &PIC); // Called on the first IR processed. - virtual void handleInitialIR(Any IR) = 0; + virtual void handleInitialIR(std::any IR) = 0; // Called before and after a pass to get the representation of the IR. - virtual void generateIRRepresentation(Any IR, StringRef PassID, + virtual void generateIRRepresentation(std::any IR, StringRef PassID, IRUnitT &Output) = 0; // Called when the pass is not iteresting. virtual void omitAfter(StringRef PassID, std::string &Name) = 0; // Called when an interesting IR has changed. virtual void handleAfter(StringRef PassID, std::string &Name, const IRUnitT &Before, const IRUnitT &After, - Any) = 0; + std::any) = 0; // Called when an interesting pass is invalidated. virtual void handleInvalidated(StringRef PassID) = 0; // Called when the IR or pass is not interesting. @@ -226,7 +226,7 @@ TextChangeReporter(bool Verbose); // Print a module dump of the first IR that is changed. - void handleInitialIR(Any IR) override; + void handleInitialIR(std::any IR) override; // Report that the IR was omitted because it did not change. void omitAfter(StringRef PassID, std::string &Name) override; // Report that the pass was invalidated. @@ -254,12 +254,12 @@ protected: // Called before and after a pass to get the representation of the IR. - void generateIRRepresentation(Any IR, StringRef PassID, + void generateIRRepresentation(std::any IR, StringRef PassID, std::string &Output) override; // Called when an interesting IR has changed. void handleAfter(StringRef PassID, std::string &Name, const std::string &Before, const std::string &After, - Any) override; + std::any) override; }; class IRChangedTester : public IRChangedPrinter { @@ -272,7 +272,7 @@ void handleIR(const std::string &IR, StringRef PassID); // Check initial IR - void handleInitialIR(Any IR) override; + void handleInitialIR(std::any IR) override; // Do nothing. void omitAfter(StringRef PassID, std::string &Name) override; // Do nothing. @@ -285,7 +285,7 @@ // Call test as interesting IR has changed. void handleAfter(StringRef PassID, std::string &Name, const std::string &Before, const std::string &After, - Any) override; + std::any) override; }; // Information that needs to be saved for a basic block in order to compare @@ -385,7 +385,7 @@ CompareFunc); // Analyze \p IR and build the IR representation in \p Data. - static void analyzeIR(Any IR, IRDataT &Data); + static void analyzeIR(std::any IR, IRDataT &Data); protected: // Generate the data for \p F into \p Data. @@ -411,13 +411,13 @@ protected: // Create a representation of the IR. - void generateIRRepresentation(Any IR, StringRef PassID, + void generateIRRepresentation(std::any IR, StringRef PassID, IRDataT &Output) override; // Called when an interesting IR has changed. void handleAfter(StringRef PassID, std::string &Name, const IRDataT &Before, - const IRDataT &After, Any) override; + const IRDataT &After, std::any) override; void handleFunctionCompare(StringRef Name, StringRef Prefix, StringRef PassID, StringRef Divider, bool InModule, unsigned Minor, @@ -449,7 +449,7 @@ private: // Implementation of pass instrumentation callbacks. - void runBeforePass(StringRef PassID, Any IR); + void runBeforePass(StringRef PassID, std::any IR); void runAfterPass(); }; @@ -497,16 +497,16 @@ bool initializeHTML(); // Called on the first IR processed. - void handleInitialIR(Any IR) override; + void handleInitialIR(std::any IR) override; // Called before and after a pass to get the representation of the IR. - void generateIRRepresentation(Any IR, StringRef PassID, + void generateIRRepresentation(std::any IR, StringRef PassID, IRDataT &Output) override; // Called when the pass is not iteresting. void omitAfter(StringRef PassID, std::string &Name) override; // Called when an interesting IR has changed. void handleAfter(StringRef PassID, std::string &Name, const IRDataT &Before, const IRDataT &After, - Any) override; + std::any) override; // Called when an interesting pass is invalidated. void handleInvalidated(StringRef PassID) override; // Called when the IR or pass is not interesting. diff --git a/llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h b/llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h --- a/llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h +++ b/llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h @@ -61,7 +61,7 @@ void registerCallbacks(PassInstrumentationCallbacks &PIC); // Implementation of pass instrumentation callbacks for new pass manager. - void runAfterPass(StringRef PassID, Any IR); + void runAfterPass(StringRef PassID, std::any IR); private: // Allow a little bias due the rounding to integral factors. diff --git a/llvm/lib/CodeGen/MachinePassManager.cpp b/llvm/lib/CodeGen/MachinePassManager.cpp --- a/llvm/lib/CodeGen/MachinePassManager.cpp +++ b/llvm/lib/CodeGen/MachinePassManager.cpp @@ -15,6 +15,8 @@ #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/IR/PassManagerImpl.h" +#include + using namespace llvm; namespace llvm { @@ -40,12 +42,12 @@ // No need to pop this callback later since MIR pipeline is flat which means // current pipeline is the top-level pipeline. Callbacks are not used after // current pipeline. - PI.pushBeforeNonSkippedPassCallback([&MFAM](StringRef PassID, Any IR) { - assert(any_isa(IR)); - const MachineFunction *MF = any_cast(IR); + PI.pushBeforeNonSkippedPassCallback([&MFAM](StringRef PassID, std::any IR) { + assert(std::any_cast(&IR)); + const MachineFunction **MF = std::any_cast(&IR); assert(MF && "Machine function should be valid for printing"); std::string Banner = std::string("After ") + std::string(PassID); - verifyMachineFunction(&MFAM, Banner, *MF); + verifyMachineFunction(&MFAM, Banner, **MF); }); } diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp --- a/llvm/lib/CodeGen/TargetPassConfig.cpp +++ b/llvm/lib/CodeGen/TargetPassConfig.cpp @@ -551,7 +551,7 @@ [=, EnableCurrent = StartBefore.empty() && StartAfter.empty(), EnableNext = std::optional(), StartBeforeCount = 0u, StartAfterCount = 0u, StopBeforeCount = 0u, - StopAfterCount = 0u](StringRef P, Any) mutable { + StopAfterCount = 0u](StringRef P, std::any) mutable { bool StartBeforePass = !StartBefore.empty() && P.contains(StartBefore); bool StartAfterPass = !StartAfter.empty() && P.contains(StartAfter); bool StopBeforePass = !StopBefore.empty() && P.contains(StopBefore); @@ -586,7 +586,7 @@ LLVMTargetMachine &LLVMTM) { // Register a callback for disabling passes. - PIC.registerShouldRunOptionalPassCallback([](StringRef P, Any) { + PIC.registerShouldRunOptionalPassCallback([](StringRef P, std::any) { #define DISABLE_PASS(Option, Name) \ if (Option && P.contains(#Name)) \ diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -17,7 +17,6 @@ #include "ConstantsContext.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" -#include "llvm/ADT/Any.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMapInfo.h" diff --git a/llvm/lib/IR/PassTimingInfo.cpp b/llvm/lib/IR/PassTimingInfo.cpp --- a/llvm/lib/IR/PassTimingInfo.cpp +++ b/llvm/lib/IR/PassTimingInfo.cpp @@ -26,6 +26,7 @@ #include "llvm/Support/Mutex.h" #include "llvm/Support/TypeName.h" #include "llvm/Support/raw_ostream.h" +#include #include using namespace llvm; @@ -301,9 +302,9 @@ return; PIC.registerBeforeNonSkippedPassCallback( - [this](StringRef P, Any) { this->startPassTimer(P); }); + [this](StringRef P, std::any) { this->startPassTimer(P); }); PIC.registerAfterPassCallback( - [this](StringRef P, Any, const PreservedAnalyses &) { + [this](StringRef P, std::any, const PreservedAnalyses &) { this->stopPassTimer(P); }); PIC.registerAfterPassInvalidatedCallback( @@ -311,9 +312,9 @@ this->stopPassTimer(P); }); PIC.registerBeforeAnalysisCallback( - [this](StringRef P, Any) { this->startAnalysisTimer(P); }); + [this](StringRef P, std::any) { this->startAnalysisTimer(P); }); PIC.registerAfterAnalysisCallback( - [this](StringRef P, Any) { this->stopAnalysisTimer(P); }); + [this](StringRef P, std::any) { this->stopAnalysisTimer(P); }); } } // namespace llvm diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp --- a/llvm/lib/Passes/StandardInstrumentations.cpp +++ b/llvm/lib/Passes/StandardInstrumentations.cpp @@ -13,7 +13,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Passes/StandardInstrumentations.h" -#include "llvm/ADT/Any.h" #include "llvm/ADT/StringRef.h" #include "llvm/Analysis/CallGraphSCCPass.h" #include "llvm/Analysis/LazyCallGraph.h" @@ -37,6 +36,7 @@ #include "llvm/Support/Regex.h" #include "llvm/Support/Signals.h" #include "llvm/Support/raw_ostream.h" +#include #include #include #include @@ -122,21 +122,19 @@ /// Extract Module out of \p IR unit. May return nullptr if \p IR does not match /// certain global filters. Will never return nullptr if \p Force is true. -const Module *unwrapModule(Any IR, bool Force = false) { - if (any_isa(IR)) - return any_cast(IR); +const Module *unwrapModule(std::any IR, bool Force = false) { + if (const auto **M = std::any_cast(&IR)) + return *M; - if (any_isa(IR)) { - const Function *F = any_cast(IR); - if (!Force && !isFunctionInPrintList(F->getName())) + if (const auto **F = std::any_cast(&IR)) { + if (!Force && !isFunctionInPrintList((*F)->getName())) return nullptr; - return F->getParent(); + return (*F)->getParent(); } - if (any_isa(IR)) { - const LazyCallGraph::SCC *C = any_cast(IR); - for (const LazyCallGraph::Node &N : *C) { + if (const auto **C = std::any_cast(&IR)) { + for (const LazyCallGraph::Node &N : **C) { const Function &F = N.getFunction(); if (Force || (!F.isDeclaration() && isFunctionInPrintList(F.getName()))) { return F.getParent(); @@ -146,9 +144,8 @@ return nullptr; } - if (any_isa(IR)) { - const Loop *L = any_cast(IR); - const Function *F = L->getHeader()->getParent(); + if (const auto **L = std::any_cast(&IR)) { + const Function *F = (*L)->getHeader()->getParent(); if (!Force && !isFunctionInPrintList(F->getName())) return nullptr; return F->getParent(); @@ -189,23 +186,20 @@ printLoop(const_cast(*L), OS); } -std::string getIRName(Any IR) { - if (any_isa(IR)) +std::string getIRName(std::any IR) { + if (std::any_cast(&IR)) return "[module]"; - if (any_isa(IR)) { - const Function *F = any_cast(IR); - return F->getName().str(); + if (const auto **F = std::any_cast(&IR)) { + return (*F)->getName().str(); } - if (any_isa(IR)) { - const LazyCallGraph::SCC *C = any_cast(IR); - return C->getName(); + if (const auto **C = std::any_cast(&IR)) { + return (*C)->getName(); } - if (any_isa(IR)) { - const Loop *L = any_cast(IR); - return L->getName().str(); + if (const auto **L = std::any_cast(&IR)) { + return (*L)->getName().str(); } llvm_unreachable("Unknown wrapped IR type"); @@ -227,32 +221,28 @@ isFunctionInPrintList("*"); } -bool shouldPrintIR(Any IR) { - if (any_isa(IR)) { - const Module *M = any_cast(IR); - return moduleContainsFilterPrintFunc(*M); +bool shouldPrintIR(std::any IR) { + if (const auto **M = std::any_cast(&IR)) { + return moduleContainsFilterPrintFunc(**M); } - if (any_isa(IR)) { - const Function *F = any_cast(IR); - return isFunctionInPrintList(F->getName()); + if (const auto **F = std::any_cast(&IR)) { + return isFunctionInPrintList((*F)->getName()); } - if (any_isa(IR)) { - const LazyCallGraph::SCC *C = any_cast(IR); - return sccContainsFilterPrintFunc(*C); + if (const auto **C = std::any_cast(&IR)) { + return sccContainsFilterPrintFunc(**C); } - if (any_isa(IR)) { - const Loop *L = any_cast(IR); - return isFunctionInPrintList(L->getHeader()->getParent()->getName()); + if (const auto **L = std::any_cast(&IR)) { + return isFunctionInPrintList((*L)->getHeader()->getParent()->getName()); } llvm_unreachable("Unknown wrapped IR type"); } /// Generic IR-printing helper that unpacks a pointer to IRUnit wrapped into -/// llvm::Any and does actual print job. -void unwrapAndPrint(raw_ostream &OS, Any IR) { +/// std::any and does actual print job. +void unwrapAndPrint(raw_ostream &OS, std::any IR) { if (!shouldPrintIR(IR)) return; @@ -263,27 +253,23 @@ return; } - if (any_isa(IR)) { - const Module *M = any_cast(IR); - printIR(OS, M); + if (const auto **M = std::any_cast(&IR)) { + printIR(OS, *M); return; } - if (any_isa(IR)) { - const Function *F = any_cast(IR); - printIR(OS, F); + if (const auto **F = std::any_cast(&IR)) { + printIR(OS, *F); return; } - if (any_isa(IR)) { - const LazyCallGraph::SCC *C = any_cast(IR); - printIR(OS, C); + if (const auto **C = std::any_cast(&IR)) { + printIR(OS, *C); return; } - if (any_isa(IR)) { - const Loop *L = any_cast(IR); - printIR(OS, L); + if (const auto **L = std::any_cast(&IR)) { + printIR(OS, *L); return; } llvm_unreachable("Unknown wrapped IR type"); @@ -312,11 +298,11 @@ } // Return the module when that is the appropriate level of comparison for \p IR. -const Module *getModuleForComparison(Any IR) { - if (any_isa(IR)) - return any_cast(IR); - if (any_isa(IR)) - return any_cast(IR) +const Module *getModuleForComparison(std::any IR) { + if (const auto **M = std::any_cast(&IR)) + return *M; + if (const auto **C = std::any_cast(&IR)) + return (*C) ->begin() ->getFunction() .getParent(); @@ -329,11 +315,11 @@ // Return true when this is a pass on IR for which printing // of changes is desired. -bool isInteresting(Any IR, StringRef PassID, StringRef PassName) { +bool isInteresting(std::any IR, StringRef PassID, StringRef PassName) { if (isIgnored(PassID) || !isPassInPrintList(PassName)) return false; - if (any_isa(IR)) - return isInterestingFunction(*any_cast(IR)); + if (const auto **F = std::any_cast(&IR)) + return isInterestingFunction(**F); return true; } @@ -344,7 +330,7 @@ } template -void ChangeReporter::saveIRBeforePass(Any IR, StringRef PassID, +void ChangeReporter::saveIRBeforePass(std::any IR, StringRef PassID, StringRef PassName) { // Always need to place something on the stack because invalidated passes // are not given the IR so it cannot be determined whether the pass was for @@ -366,7 +352,7 @@ } template -void ChangeReporter::handleIRAfterPass(Any IR, StringRef PassID, +void ChangeReporter::handleIRAfterPass(std::any IR, StringRef PassID, StringRef PassName) { assert(!BeforeStack.empty() && "Unexpected empty stack encountered."); @@ -411,12 +397,12 @@ template void ChangeReporter::registerRequiredCallbacks( PassInstrumentationCallbacks &PIC) { - PIC.registerBeforeNonSkippedPassCallback([&PIC, this](StringRef P, Any IR) { + PIC.registerBeforeNonSkippedPassCallback([&PIC, this](StringRef P, std::any IR) { saveIRBeforePass(IR, P, PIC.getPassNameForClassName(P)); }); PIC.registerAfterPassCallback( - [&PIC, this](StringRef P, Any IR, const PreservedAnalyses &) { + [&PIC, this](StringRef P, std::any IR, const PreservedAnalyses &) { handleIRAfterPass(IR, P, PIC.getPassNameForClassName(P)); }); PIC.registerAfterPassInvalidatedCallback( @@ -429,7 +415,7 @@ TextChangeReporter::TextChangeReporter(bool Verbose) : ChangeReporter(Verbose), Out(dbgs()) {} -template void TextChangeReporter::handleInitialIR(Any IR) { +template void TextChangeReporter::handleInitialIR(std::any IR) { // Always print the module. // Unwrap and print directly to avoid filtering problems in general routines. auto *M = unwrapModule(IR, /*Force=*/true); @@ -470,7 +456,7 @@ TextChangeReporter::registerRequiredCallbacks(PIC); } -void IRChangedPrinter::generateIRRepresentation(Any IR, StringRef PassID, +void IRChangedPrinter::generateIRRepresentation(std::any IR, StringRef PassID, std::string &Output) { raw_string_ostream OS(Output); unwrapAndPrint(OS, IR); @@ -479,7 +465,7 @@ void IRChangedPrinter::handleAfter(StringRef PassID, std::string &Name, const std::string &Before, - const std::string &After, Any) { + const std::string &After, std::any) { // Report the IR before the changes when requested. if (PrintChangedBefore) Out << "*** IR Dump Before " << PassID << " on " << Name << " ***\n" @@ -528,7 +514,7 @@ dbgs() << "Unable to remove temporary file."; } -void IRChangedTester::handleInitialIR(Any IR) { +void IRChangedTester::handleInitialIR(std::any IR) { // Always test the initial module. // Unwrap and print directly to avoid filtering problems in general routines. std::string S; @@ -542,7 +528,7 @@ void IRChangedTester::handleIgnored(StringRef PassID, std::string &Name) {} void IRChangedTester::handleAfter(StringRef PassID, std::string &Name, const std::string &Before, - const std::string &After, Any) { + const std::string &After, std::any) { handleIR(After, PassID); } @@ -646,7 +632,8 @@ }); } -template void IRComparer::analyzeIR(Any IR, IRDataT &Data) { +template +void IRComparer::analyzeIR(std::any IR, IRDataT &Data) { if (const Module *M = getModuleForComparison(IR)) { // Create data for each existing/interesting function in the module. for (const Function &F : *M) @@ -654,13 +641,12 @@ return; } - const Function *F = nullptr; - if (any_isa(IR)) - F = any_cast(IR); - else { - assert(any_isa(IR) && "Unknown IR unit."); - const Loop *L = any_cast(IR); - F = L->getHeader()->getParent(); + const Function **FPtr = std::any_cast(&IR); + const Function *F = FPtr ? *FPtr : nullptr; + if (!F) { + const Loop **L = std::any_cast(&IR); + assert(L && "Unknown IR unit."); + F = (*L)->getHeader()->getParent(); } assert(F && "Unknown IR unit."); generateFunctionData(Data, *F); @@ -691,7 +677,7 @@ assert(ModuleDescStack.empty() && "ModuleDescStack is not empty at exit"); } -void PrintIRInstrumentation::pushModuleDesc(StringRef PassID, Any IR) { +void PrintIRInstrumentation::pushModuleDesc(StringRef PassID, std::any IR) { const Module *M = unwrapModule(IR); ModuleDescStack.emplace_back(M, getIRName(IR), PassID); } @@ -704,7 +690,7 @@ return ModuleDesc; } -void PrintIRInstrumentation::printBeforePass(StringRef PassID, Any IR) { +void PrintIRInstrumentation::printBeforePass(StringRef PassID, std::any IR) { if (isIgnored(PassID)) return; @@ -726,7 +712,7 @@ unwrapAndPrint(dbgs(), IR); } -void PrintIRInstrumentation::printAfterPass(StringRef PassID, Any IR) { +void PrintIRInstrumentation::printAfterPass(StringRef PassID, std::any IR) { if (isIgnored(PassID)) return; @@ -794,11 +780,11 @@ // for later use in AfterPassInvalidated. if (shouldPrintBeforeSomePass() || shouldPrintAfterSomePass()) PIC.registerBeforeNonSkippedPassCallback( - [this](StringRef P, Any IR) { this->printBeforePass(P, IR); }); + [this](StringRef P, std::any IR) { this->printBeforePass(P, IR); }); if (shouldPrintAfterSomePass()) { PIC.registerAfterPassCallback( - [this](StringRef P, Any IR, const PreservedAnalyses &) { + [this](StringRef P, std::any IR, const PreservedAnalyses &) { this->printAfterPass(P, IR); }); PIC.registerAfterPassInvalidatedCallback( @@ -811,15 +797,15 @@ void OptNoneInstrumentation::registerCallbacks( PassInstrumentationCallbacks &PIC) { PIC.registerShouldRunOptionalPassCallback( - [this](StringRef P, Any IR) { return this->shouldRun(P, IR); }); + [this](StringRef P, std::any IR) { return this->shouldRun(P, IR); }); } -bool OptNoneInstrumentation::shouldRun(StringRef PassID, Any IR) { - const Function *F = nullptr; - if (any_isa(IR)) { - F = any_cast(IR); - } else if (any_isa(IR)) { - F = any_cast(IR)->getHeader()->getParent(); +bool OptNoneInstrumentation::shouldRun(StringRef PassID, std::any IR) { + const Function **FPtr = std::any_cast(&IR); + const Function *F = FPtr ? *FPtr : nullptr; + if (!F) { + if (const auto **L = std::any_cast(&IR)) + F = (*L)->getHeader()->getParent(); } bool ShouldRun = !(F && F->hasOptNone()); if (!ShouldRun && DebugLogging) { @@ -829,7 +815,7 @@ return ShouldRun; } -bool OptPassGateInstrumentation::shouldRun(StringRef PassName, Any IR) { +bool OptPassGateInstrumentation::shouldRun(StringRef PassName, std::any IR) { if (isIgnored(PassName)) return true; @@ -856,7 +842,7 @@ if (!PassGate.isEnabled()) return; - PIC.registerShouldRunOptionalPassCallback([this](StringRef PassName, Any IR) { + PIC.registerShouldRunOptionalPassCallback([this](StringRef PassName, std::any IR) { return this->shouldRun(PassName, IR); }); } @@ -881,27 +867,27 @@ } PIC.registerBeforeSkippedPassCallback([this, SpecialPasses](StringRef PassID, - Any IR) { + std::any IR) { assert(!isSpecialPass(PassID, SpecialPasses) && "Unexpectedly skipping special pass"); print() << "Skipping pass: " << PassID << " on " << getIRName(IR) << "\n"; }); PIC.registerBeforeNonSkippedPassCallback([this, SpecialPasses]( - StringRef PassID, Any IR) { + StringRef PassID, std::any IR) { if (isSpecialPass(PassID, SpecialPasses)) return; auto &OS = print(); OS << "Running pass: " << PassID << " on " << getIRName(IR); - if (any_isa(IR)) { - unsigned Count = any_cast(IR)->getInstructionCount(); + if (const auto **F = std::any_cast(&IR)) { + unsigned Count = (*F)->getInstructionCount(); OS << " (" << Count << " instruction"; if (Count != 1) OS << 's'; OS << ')'; - } else if (any_isa(IR)) { - int Count = any_cast(IR)->size(); + } else if (const auto **C = std::any_cast(&IR)) { + int Count = (*C)->size(); OS << " (" << Count << " node"; if (Count != 1) OS << 's'; @@ -911,7 +897,7 @@ Indent += 2; }); PIC.registerAfterPassCallback( - [this, SpecialPasses](StringRef PassID, Any IR, + [this, SpecialPasses](StringRef PassID, std::any IR, const PreservedAnalyses &) { if (isSpecialPass(PassID, SpecialPasses)) return; @@ -919,7 +905,7 @@ Indent -= 2; }); PIC.registerAfterPassInvalidatedCallback( - [this, SpecialPasses](StringRef PassID, Any IR) { + [this, SpecialPasses](StringRef PassID, std::any IR) { if (isSpecialPass(PassID, SpecialPasses)) return; @@ -927,14 +913,15 @@ }); if (!Opts.SkipAnalyses) { - PIC.registerBeforeAnalysisCallback([this](StringRef PassID, Any IR) { + PIC.registerBeforeAnalysisCallback([this](StringRef PassID, std::any IR) { print() << "Running analysis: " << PassID << " on " << getIRName(IR) << "\n"; Indent += 2; }); PIC.registerAfterAnalysisCallback( - [this](StringRef PassID, Any IR) { Indent -= 2; }); - PIC.registerAnalysisInvalidatedCallback([this](StringRef PassID, Any IR) { + [this](StringRef PassID, std::any IR) { Indent -= 2; }); + PIC.registerAnalysisInvalidatedCallback([this](StringRef PassID, + std::any IR) { print() << "Invalidating analysis: " << PassID << " on " << getIRName(IR) << "\n"; }); @@ -1099,18 +1086,19 @@ report_fatal_error(Twine("CFG unexpectedly changed by ", Pass)); }; - PIC.registerBeforeNonSkippedPassCallback([this, &FAM](StringRef P, Any IR) { + PIC.registerBeforeNonSkippedPassCallback( + [this, &FAM](StringRef P, std::any IR) { #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS - assert(&PassStack.emplace_back(P)); + assert(&PassStack.emplace_back(P)); #endif - (void)this; - if (!any_isa(IR)) - return; + (void)this; + const auto **F = std::any_cast(&IR); + if (!F) + return; - const auto *F = any_cast(IR); - // Make sure a fresh CFG snapshot is available before the pass. - FAM.getResult(*const_cast(F)); - }); + // Make sure a fresh CFG snapshot is available before the pass. + FAM.getResult(*const_cast(*F)); + }); PIC.registerAfterPassInvalidatedCallback( [this](StringRef P, const PreservedAnalyses &PassPA) { @@ -1122,7 +1110,7 @@ }); PIC.registerAfterPassCallback([this, &FAM, - checkCFG](StringRef P, Any IR, + checkCFG](StringRef P, std::any IR, const PreservedAnalyses &PassPA) { #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS assert(PassStack.pop_back_val() == P && @@ -1130,67 +1118,71 @@ #endif (void)this; - if (!any_isa(IR)) + const auto **F = std::any_cast(&IR); + if (!F) return; if (!PassPA.allAnalysesInSetPreserved() && !PassPA.allAnalysesInSetPreserved>()) return; - const auto *F = any_cast(IR); if (auto *GraphBefore = FAM.getCachedResult( - *const_cast(F))) - checkCFG(P, F->getName(), *GraphBefore, - CFG(F, /* TrackBBLifetime */ false)); + *const_cast(*F))) + checkCFG(P, (*F)->getName(), *GraphBefore, + CFG(*F, /* TrackBBLifetime */ false)); }); } void VerifyInstrumentation::registerCallbacks( PassInstrumentationCallbacks &PIC) { PIC.registerAfterPassCallback( - [this](StringRef P, Any IR, const PreservedAnalyses &PassPA) { + [this](StringRef P, std::any IR, const PreservedAnalyses &PassPA) { if (isIgnored(P) || P == "VerifierPass") return; - if (any_isa(IR) || any_isa(IR)) { - const Function *F; - if (any_isa(IR)) - F = any_cast(IR)->getHeader()->getParent(); - else - F = any_cast(IR); + const Function **FPtr = std::any_cast(&IR); + const Function *F = FPtr ? *FPtr : nullptr; + if (!F) { + if (const auto **L = std::any_cast(&IR)) + F = (*L)->getHeader()->getParent(); + } + + if (F) { if (DebugLogging) dbgs() << "Verifying function " << F->getName() << "\n"; if (verifyFunction(*F, &errs())) report_fatal_error("Broken function found, compilation aborted!"); - } else if (any_isa(IR) || - any_isa(IR)) { - const Module *M; - if (any_isa(IR)) - M = any_cast(IR) - ->begin() - ->getFunction() - .getParent(); - else - M = any_cast(IR); - if (DebugLogging) - dbgs() << "Verifying module " << M->getName() << "\n"; - - if (verifyModule(*M, &errs())) - report_fatal_error("Broken module found, compilation aborted!"); + } else { + const Module **MPtr = std::any_cast(&IR); + const Module *M = MPtr ? *MPtr : nullptr; + if (!M) { + if (const auto **C = std::any_cast(&IR)) + M = (*C)->begin()->getFunction().getParent(); + } + + if (M) { + if (DebugLogging) + dbgs() << "Verifying module " << M->getName() << "\n"; + + if (verifyModule(*M, &errs())) + report_fatal_error("Broken module found, compilation aborted!"); + } } }); } InLineChangePrinter::~InLineChangePrinter() = default; -void InLineChangePrinter::generateIRRepresentation(Any IR, StringRef PassID, +void InLineChangePrinter::generateIRRepresentation(std::any IR, + StringRef PassID, IRDataT &D) { IRComparer::analyzeIR(IR, D); } void InLineChangePrinter::handleAfter(StringRef PassID, std::string &Name, const IRDataT &Before, - const IRDataT &After, Any IR) { + const IRDataT &After, + std::any IR) { SmallString<20> Banner = formatv("*** IR Dump After {0} on {1} ***\n", PassID, Name); Out << Banner; @@ -1241,9 +1233,9 @@ if (!getTimeTraceProfilerInstance()) return; PIC.registerBeforeNonSkippedPassCallback( - [this](StringRef P, Any IR) { this->runBeforePass(P, IR); }); + [this](StringRef P, std::any IR) { this->runBeforePass(P, IR); }); PIC.registerAfterPassCallback( - [this](StringRef P, Any IR, const PreservedAnalyses &) { + [this](StringRef P, std::any IR, const PreservedAnalyses &) { this->runAfterPass(); }, true); @@ -1251,12 +1243,12 @@ [this](StringRef P, const PreservedAnalyses &) { this->runAfterPass(); }, true); PIC.registerBeforeAnalysisCallback( - [this](StringRef P, Any IR) { this->runBeforePass(P, IR); }); + [this](StringRef P, std::any IR) { this->runBeforePass(P, IR); }); PIC.registerAfterAnalysisCallback( - [this](StringRef P, Any IR) { this->runAfterPass(); }, true); + [this](StringRef P, std::any IR) { this->runAfterPass(); }, true); } -void TimeProfilingPassesHandler::runBeforePass(StringRef PassID, Any IR) { +void TimeProfilingPassesHandler::runBeforePass(StringRef PassID, std::any IR) { timeTraceProfilerBegin(PassID, getIRName(IR)); } @@ -1949,7 +1941,7 @@ return S.c_str(); } -void DotCfgChangeReporter::handleInitialIR(Any IR) { +void DotCfgChangeReporter::handleInitialIR(std::any IR) { assert(HTML && "Expected outstream to be set"); *HTML << "\n" @@ -1973,7 +1965,8 @@ ++N; } -void DotCfgChangeReporter::generateIRRepresentation(Any IR, StringRef PassID, +void DotCfgChangeReporter::generateIRRepresentation(std::any IR, + StringRef PassID, IRDataT &Data) { IRComparer::analyzeIR(IR, Data); } @@ -1989,7 +1982,8 @@ void DotCfgChangeReporter::handleAfter(StringRef PassID, std::string &Name, const IRDataT &Before, - const IRDataT &After, Any IR) { + const IRDataT &After, + std::any IR) { assert(HTML && "Expected outstream to be set"); IRComparer(Before, After) .compare(getModuleForComparison(IR), @@ -2152,7 +2146,7 @@ CrashReporter = this; PIC.registerBeforeNonSkippedPassCallback([&PIC, this](StringRef PassID, - Any IR) { + std::any IR) { SavedIR.clear(); raw_string_ostream OS(SavedIR); OS << formatv("*** Dump of {0}IR Before Last Pass {1}", diff --git a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp --- a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp @@ -87,25 +87,25 @@ void PseudoProbeVerifier::registerCallbacks(PassInstrumentationCallbacks &PIC) { if (VerifyPseudoProbe) { PIC.registerAfterPassCallback( - [this](StringRef P, Any IR, const PreservedAnalyses &) { + [this](StringRef P, std::any IR, const PreservedAnalyses &) { this->runAfterPass(P, IR); }); } } // Callback to run after each transformation for the new pass manager. -void PseudoProbeVerifier::runAfterPass(StringRef PassID, Any IR) { +void PseudoProbeVerifier::runAfterPass(StringRef PassID, std::any IR) { std::string Banner = "\n*** Pseudo Probe Verification After " + PassID.str() + " ***\n"; dbgs() << Banner; - if (any_isa(IR)) - runAfterPass(any_cast(IR)); - else if (any_isa(IR)) - runAfterPass(any_cast(IR)); - else if (any_isa(IR)) - runAfterPass(any_cast(IR)); - else if (any_isa(IR)) - runAfterPass(any_cast(IR)); + if (const auto **M = std::any_cast(&IR)) + runAfterPass(*M); + else if (const auto **F = std::any_cast(&IR)) + runAfterPass(*F); + else if (const auto **C = std::any_cast(&IR)) + runAfterPass(*C); + else if (const auto **L = std::any_cast(&IR)) + runAfterPass(*L); else llvm_unreachable("Unknown IR unit"); } diff --git a/llvm/lib/Transforms/Scalar/LoopPassManager.cpp b/llvm/lib/Transforms/Scalar/LoopPassManager.cpp --- a/llvm/lib/Transforms/Scalar/LoopPassManager.cpp +++ b/llvm/lib/Transforms/Scalar/LoopPassManager.cpp @@ -265,13 +265,14 @@ } #ifndef NDEBUG - PI.pushBeforeNonSkippedPassCallback([&LAR, &LI](StringRef PassID, Any IR) { + PI.pushBeforeNonSkippedPassCallback([&LAR, &LI](StringRef PassID, std::any IR) { if (isSpecialPass(PassID, {"PassManager"})) return; - assert(any_isa(IR) || any_isa(IR)); - const Loop *L = any_isa(IR) - ? any_cast(IR) - : &any_cast(IR)->getOutermostLoop(); + assert(std::any_cast(&IR) || std::any_cast(&IR)); + const Loop **LPtr = std::any_cast(&IR); + const Loop *L = LPtr ? *LPtr : nullptr; + if (!L) + L = &std::any_cast(IR)->getOutermostLoop(); assert(L && "Loop should be valid for printing"); // Verify the loop structure and LCSSA form before visiting the loop. diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp --- a/llvm/lib/Transforms/Utils/Debugify.cpp +++ b/llvm/lib/Transforms/Utils/Debugify.cpp @@ -29,6 +29,8 @@ #include "llvm/Support/JSON.h" #include +#include + #define DEBUG_TYPE "debugify" using namespace llvm; @@ -1028,22 +1030,22 @@ void DebugifyEachInstrumentation::registerCallbacks( PassInstrumentationCallbacks &PIC) { - PIC.registerBeforeNonSkippedPassCallback([this](StringRef P, Any IR) { + PIC.registerBeforeNonSkippedPassCallback([this](StringRef P, std::any IR) { if (isIgnoredPass(P)) return; - if (any_isa(IR)) - applyDebugify(*const_cast(any_cast(IR)), + if (const auto **F = std::any_cast(&IR)) + applyDebugify(*const_cast(*F), Mode, DebugInfoBeforePass, P); - else if (any_isa(IR)) - applyDebugify(*const_cast(any_cast(IR)), + else if (const auto **M = std::any_cast(&IR)) + applyDebugify(*const_cast(*M), Mode, DebugInfoBeforePass, P); }); - PIC.registerAfterPassCallback([this](StringRef P, Any IR, + PIC.registerAfterPassCallback([this](StringRef P, std::any IR, const PreservedAnalyses &PassPA) { if (isIgnoredPass(P)) return; - if (any_isa(IR)) { - auto &F = *const_cast(any_cast(IR)); + if (const auto **CF = std::any_cast(&IR)) { + auto &F = *const_cast(*CF); Module &M = *F.getParent(); auto It = F.getIterator(); if (Mode == DebugifyMode::SyntheticDebugInfo) @@ -1054,8 +1056,8 @@ M, make_range(It, std::next(It)), *DebugInfoBeforePass, "CheckModuleDebugify (original debuginfo)", P, OrigDIVerifyBugsReportFilePath); - } else if (any_isa(IR)) { - auto &M = *const_cast(any_cast(IR)); + } else if (const auto **CM = std::any_cast(&IR)) { + auto &M = *const_cast(*CM); if (Mode == DebugifyMode::SyntheticDebugInfo) checkDebugifyMetadata(M, M.functions(), P, "CheckModuleDebugify", /*Strip=*/true, DIStatsMap); diff --git a/llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp b/llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp --- a/llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp +++ b/llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp @@ -29,7 +29,7 @@ PassInstrumentationCallbacks PIC; PIC.registerShouldRunOptionalPassCallback( - [&](StringRef, Any) { return !O.shouldKeep(); }); + [&](StringRef, std::any) { return !O.shouldKeep(); }); PassBuilder PB(nullptr, PipelineTuningOptions(), std::nullopt, &PIC); PB.registerModuleAnalyses(MAM); diff --git a/llvm/unittests/IR/PassBuilderCallbacksTest.cpp b/llvm/unittests/IR/PassBuilderCallbacksTest.cpp --- a/llvm/unittests/IR/PassBuilderCallbacksTest.cpp +++ b/llvm/unittests/IR/PassBuilderCallbacksTest.cpp @@ -7,10 +7,10 @@ //===----------------------------------------------------------------------===// #include "llvm/Testing/Support/Error.h" +#include #include #include #include -#include #include #include #include @@ -281,7 +281,7 @@ } /// Helper for HasName matcher that returns getName both for IRUnit and -/// for IRUnit pointer wrapper into llvm::Any (wrapped by PassInstrumentation). +/// for IRUnit pointer wrapper into std::any (wrapped by PassInstrumentation). template std::string getName(const IRUnitT &IR) { return std::string(IR.getName()); } @@ -290,17 +290,17 @@ return std::string(name); } -template <> std::string getName(const llvm::Any &WrappedIR) { - if (any_isa(WrappedIR)) - return any_cast(WrappedIR)->getName().str(); - if (any_isa(WrappedIR)) - return any_cast(WrappedIR)->getName().str(); - if (any_isa(WrappedIR)) - return any_cast(WrappedIR)->getName().str(); - if (any_isa(WrappedIR)) - return any_cast(WrappedIR)->getName().str(); - if (any_isa(WrappedIR)) - return any_cast(WrappedIR)->getName(); +template <> std::string getName(const std::any &WrappedIR) { + if (const auto *const *M = std::any_cast(&WrappedIR)) + return (*M)->getName().str(); + if (const auto *const *F = std::any_cast(&WrappedIR)) + return (*F)->getName().str(); + if (const auto *const *L = std::any_cast(&WrappedIR)) + return (*L)->getName().str(); + if (const auto *const *L = std::any_cast(&WrappedIR)) + return (*L)->getName().str(); + if (const auto *const *C = std::any_cast(&WrappedIR)) + return (*C)->getName(); return ""; } /// Define a custom matcher for objects which support a 'getName' method. @@ -334,42 +334,42 @@ MockPassInstrumentationCallbacks() { ON_CALL(*this, runBeforePass(_, _)).WillByDefault(Return(true)); } - MOCK_METHOD2(runBeforePass, bool(StringRef PassID, llvm::Any)); - MOCK_METHOD2(runBeforeSkippedPass, void(StringRef PassID, llvm::Any)); - MOCK_METHOD2(runBeforeNonSkippedPass, void(StringRef PassID, llvm::Any)); + MOCK_METHOD2(runBeforePass, bool(StringRef PassID, std::any)); + MOCK_METHOD2(runBeforeSkippedPass, void(StringRef PassID, std::any)); + MOCK_METHOD2(runBeforeNonSkippedPass, void(StringRef PassID, std::any)); MOCK_METHOD3(runAfterPass, - void(StringRef PassID, llvm::Any, const PreservedAnalyses &PA)); + void(StringRef PassID, std::any, const PreservedAnalyses &PA)); MOCK_METHOD2(runAfterPassInvalidated, void(StringRef PassID, const PreservedAnalyses &PA)); - MOCK_METHOD2(runBeforeAnalysis, void(StringRef PassID, llvm::Any)); - MOCK_METHOD2(runAfterAnalysis, void(StringRef PassID, llvm::Any)); + MOCK_METHOD2(runBeforeAnalysis, void(StringRef PassID, std::any)); + MOCK_METHOD2(runAfterAnalysis, void(StringRef PassID, std::any)); void registerPassInstrumentation() { Callbacks.registerShouldRunOptionalPassCallback( - [this](StringRef P, llvm::Any IR) { + [this](StringRef P, std::any IR) { return this->runBeforePass(P, IR); }); Callbacks.registerBeforeSkippedPassCallback( - [this](StringRef P, llvm::Any IR) { + [this](StringRef P, std::any IR) { this->runBeforeSkippedPass(P, IR); }); Callbacks.registerBeforeNonSkippedPassCallback( - [this](StringRef P, llvm::Any IR) { + [this](StringRef P, std::any IR) { this->runBeforeNonSkippedPass(P, IR); }); Callbacks.registerAfterPassCallback( - [this](StringRef P, llvm::Any IR, const PreservedAnalyses &PA) { + [this](StringRef P, std::any IR, const PreservedAnalyses &PA) { this->runAfterPass(P, IR, PA); }); Callbacks.registerAfterPassInvalidatedCallback( [this](StringRef P, const PreservedAnalyses &PA) { this->runAfterPassInvalidated(P, PA); }); - Callbacks.registerBeforeAnalysisCallback([this](StringRef P, llvm::Any IR) { + Callbacks.registerBeforeAnalysisCallback([this](StringRef P, std::any IR) { return this->runBeforeAnalysis(P, IR); }); Callbacks.registerAfterAnalysisCallback( - [this](StringRef P, llvm::Any IR) { this->runAfterAnalysis(P, IR); }); + [this](StringRef P, std::any IR) { this->runAfterAnalysis(P, IR); }); } void ignoreNonMockPassInstrumentation(StringRef IRName) {