1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-23 13:02:52 +02:00
llvm-mirror/unittests/Passes/TestPlugin.cxx
Philip Pfaffe 3d76c2d6f6 Re-land r329273: [Plugins] Add a slim plugin API to work together with the new PM
Fix unittest: Do not link LLVM into the test plugin.
Additionally, remove an unrelated change that slipped in in r329273.

llvm-svn: 329293
2018-04-05 15:04:13 +00:00

40 lines
1.2 KiB
C++

//===- unittests/Passes/Plugins/Plugin.cxx --------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "TestPlugin.h"
using namespace llvm;
struct TestModulePass : public PassInfoMixin<TestModulePass> {
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM) {
return PreservedAnalyses::all();
}
};
void registerCallbacks(PassBuilder &PB) {
PB.registerPipelineParsingCallback(
[](StringRef Name, ModulePassManager &PM,
ArrayRef<PassBuilder::PipelineElement> InnerPipeline) {
if (Name == "plugin-pass") {
PM.addPass(TestModulePass());
return true;
}
return false;
});
}
extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK LLVM_PLUGIN_EXPORT
llvmGetPassPluginInfo() {
return {LLVM_PLUGIN_API_VERSION, TEST_PLUGIN_NAME, TEST_PLUGIN_VERSION,
registerCallbacks};
}