Issue 144992
Summary Where and When does the outer customized pass plugin execute exactly?
Labels new issue
Assignees
Reporter TJU-PanYizhe
    I used `PassInfoMixin` to implement my own pass plugin and load it with `clang-19 -fpass-plugin="build/libRCXLP.so" tests/test.c -S -emit-llvm -o tests/out/test_clang.ll` command.

I wonder Where and When does this pass plugin execute exactly?

- before all other passes implemented in llvm
- or after all other passes
- or ... ?

This is my pass plugin code

```C++
#include "RCXLP.h"

using namespace std;
using namespace llvm;

namespace
{
  class MY_TEST_Pass : public PassInfoMixin<MY_TEST_Pass>
  {
  public:
 vector<RCXLP::RIRInstruction> rir_instructions;

    PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
    {
      cout << "My first pass plugin" << endl;
      return PreservedAnalyses::all();
    }
 };
}

llvm::PassPluginLibraryInfo getMyPluginInfo()
{
  return {
 LLVM_PLUGIN_API_VERSION, "MY_TEST_Pass", "v0.1",
 [](llvm::PassBuilder &PB)
      {
 PB.registerPipelineStartEPCallback(
            [](ModulePassManager &MPM, OptimizationLevel Level)
            {
              FunctionPassManager FPM;
              MPM.addPass(MY_TEST_Pass());
            });
 PB.registerPipelineParsingCallback(
            [](
 llvm::StringRef Name, llvm::ModulePassManager &MPM,
 llvm::ArrayRef<llvm::PassBuilder::PipelineElement>)
            {
 if (Name == "my-test")
              {
 MPM.addPass(MY_TEST_Pass());
                return true;
              }
 return false;
            });
      }};
}

extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo
llvmGetPassPluginInfo()
{
  return getMyPluginInfo();
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to