-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathllvm-pass.so.cc
More file actions
34 lines (27 loc) · 984 Bytes
/
llvm-pass.so.cc
File metadata and controls
34 lines (27 loc) · 984 Bytes
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
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/IR/IRBuilder.h"
using namespace llvm;
struct LLVMPass : public PassInfoMixin<LLVMPass> {
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
};
PreservedAnalyses LLVMPass::run(Module &M, ModuleAnalysisManager &MAM) {
LLVMContext &Ctx = M.getContext();
IntegerType *Int32Ty = IntegerType::getInt32Ty(Ctx);
FunctionCallee debug_func = M.getOrInsertFunction("debug", Int32Ty);
ConstantInt *debug_arg = ConstantInt::get(Int32Ty, 48763);
for (auto &F : M) {
errs() << "func: " << F.getName() << "\n";
}
return PreservedAnalyses::none();
}
extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK
llvmGetPassPluginInfo() {
return {LLVM_PLUGIN_API_VERSION, "LLVMPass", "1.0",
[](PassBuilder &PB) {
PB.registerOptimizerLastEPCallback(
[](ModulePassManager &MPM, OptimizationLevel OL) {
MPM.addPass(LLVMPass());
});
}};
}