1 //===- unittests/Passes/Plugins/Plugin.cpp --------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Passes/PassBuilder.h"
11 #include "llvm/Passes/PassPlugin.h"
13 #include "TestPlugin.h"
17 struct TestModulePass
: public PassInfoMixin
<TestModulePass
> {
18 PreservedAnalyses
run(Module
&M
, ModuleAnalysisManager
&MAM
) {
19 return PreservedAnalyses::all();
23 void registerCallbacks(PassBuilder
&PB
) {
24 PB
.registerPipelineParsingCallback(
25 [](StringRef Name
, ModulePassManager
&PM
,
26 ArrayRef
<PassBuilder::PipelineElement
> InnerPipeline
) {
27 if (Name
== "plugin-pass") {
28 PM
.addPass(TestModulePass());
35 extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK
36 llvmGetPassPluginInfo() {
37 return {LLVM_PLUGIN_API_VERSION
, TEST_PLUGIN_NAME
, TEST_PLUGIN_VERSION
,