----------------------------------------------------------------------------- New PM Registration -----------------------------------------------------------------------------
| 78 | // New PM Registration |
| 79 | //----------------------------------------------------------------------------- |
| 80 | llvm::PassPluginLibraryInfo getOpcodeCounterPluginInfo() { |
| 81 | return { |
| 82 | LLVM_PLUGIN_API_VERSION, "OpcodeCounter", LLVM_VERSION_STRING, |
| 83 | [](PassBuilder &PB) { |
| 84 | // #1 REGISTRATION FOR "opt -passes=print<opcode-counter>" |
| 85 | // Register OpcodeCounterPrinter so that it can be used when |
| 86 | // specifying pass pipelines with `-passes=`. |
| 87 | PB.registerPipelineParsingCallback( |
| 88 | [&](StringRef Name, FunctionPassManager &FPM, |
| 89 | ArrayRef<PassBuilder::PipelineElement>) { |
| 90 | if (Name == "print<opcode-counter>") { |
| 91 | FPM.addPass(OpcodeCounterPrinter(llvm::errs())); |
| 92 | return true; |
| 93 | } |
| 94 | return false; |
| 95 | }); |
| 96 | // #2 REGISTRATION FOR "-O{1|2|3|s}" |
| 97 | // Register OpcodeCounterPrinter as a step of an existing pipeline. |
| 98 | // The insertion point is specified by using the |
| 99 | // 'registerVectorizerStartEPCallback' callback. To be more precise, |
| 100 | // using this callback means that OpcodeCounterPrinter will be called |
| 101 | // whenever the vectoriser is used (i.e. when using '-O{1|2|3|s}'. |
| 102 | PB.registerVectorizerStartEPCallback( |
| 103 | [](llvm::FunctionPassManager &PM, |
| 104 | llvm::OptimizationLevel Level) { |
| 105 | PM.addPass(OpcodeCounterPrinter(llvm::errs())); |
| 106 | }); |
| 107 | // #3 REGISTRATION FOR "FAM.getResult<OpcodeCounter>(Func)" |
| 108 | // Register OpcodeCounter as an analysis pass. This is required so that |
| 109 | // OpcodeCounterPrinter (or any other pass) can request the results |
| 110 | // of OpcodeCounter. |
| 111 | PB.registerAnalysisRegistrationCallback( |
| 112 | [](FunctionAnalysisManager &FAM) { |
| 113 | FAM.registerPass([&] { return OpcodeCounter(); }); |
| 114 | }); |
| 115 | } |
| 116 | }; |
| 117 | } |
| 118 | |
| 119 | extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo |
| 120 | llvmGetPassPluginInfo() { |
no test coverage detected