-
Notifications
You must be signed in to change notification settings - Fork 1
/
testbed.cpp
39 lines (33 loc) · 1.18 KB
/
testbed.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/Module.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/Pass.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include <iostream>
using namespace llvm;
class IRTestbed : public PassInfoMixin<IRTestbed> {
public:
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
};
PreservedAnalyses IRTestbed::run(Module &M, ModuleAnalysisManager &MAM) {
// TODO: your pass code.
return PreservedAnalyses::all();
}
extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK
llvmGetPassPluginInfo() {
return {LLVM_PLUGIN_API_VERSION, "IRTestbed", "v0.0",
[](PassBuilder &PB) {
/* Register this pass to a pipeline point when you want it to be called.
* See the relevant doxygen for other callbacks.
* (https://llvm.org/doxygen/classllvm_1_1PassBuilder.html) */
PB.registerOptimizerLastEPCallback(
[](ModulePassManager &MPM, OptimizationLevel OL) {
MPM.addPass(IRTestbed());
});
}};
}