[x86/SLH] Fix an issue where we wouldn't harden any loads if we found
[llvm-complete.git] / unittests / Passes / TestPlugin.cpp
blob3dc5cdc84768f00d1512b3bc2294fc78632c834a
1 //===- unittests/Passes/Plugins/Plugin.cpp --------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Passes/PassBuilder.h"
11 #include "llvm/Passes/PassPlugin.h"
13 #include "TestPlugin.h"
15 using namespace llvm;
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());
29 return true;
31 return false;
32 });
35 extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK
36 llvmGetPassPluginInfo() {
37 return {LLVM_PLUGIN_API_VERSION, TEST_PLUGIN_NAME, TEST_PLUGIN_VERSION,
38 registerCallbacks};