-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpass.cpp
More file actions
66 lines (61 loc) · 2.51 KB
/
Copy pathpass.cpp
File metadata and controls
66 lines (61 loc) · 2.51 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "pass.h"
#include "all_pass/remove_leak.h"
#include "all_pass/remove_panic.h"
#include "all_pass/control_flow_flattening.h"
#include "all_pass/basic_block_split.h"
#include "all_pass/instruction_substitute.h"
/// cpp 26, llvm 22
/// 主要面向rust设计但也具有通用性
extern "C" LLVM_ATTRIBUTE_WEAK PassPluginLibraryInfo
llvmGetPassPluginInfo() {
return {
LLVM_PLUGIN_API_VERSION,
"ZzPass",
"22.1_1.0",
[](PassBuilder &PB) {
PB.registerPipelineParsingCallback(
[](const StringRef Name,
ModulePassManager &MPM,
ArrayRef<PassBuilder::PipelineElement>) {
if (Name == "remove_leak" || Name == "rl") {
MPM.addPass(RemoveLeak());
return true;
}
if (Name == "remove_panic" || Name == "rp") {
MPM.addPass(RemovePanic());
FunctionPassManager FPM;
FPM.addPass(ADCEPass());
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
MPM.addPass(GlobalDCEPass());
return true;
}
if (Name == "control_flow_flattening" || Name == "cff") {
FunctionPassManager FPM;
FPM.addPass(ControlFlowFlattening());
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
return true;
}
if (Name == "basic_block_split" || Name == "bbs") {
FunctionPassManager FPM;
FPM.addPass(BasicBlockSplit());
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
return true;
}
if (Name == "instruction_substitute" || Name == "is") {
FunctionPassManager FPM;
FPM.addPass(InstructionSubstitute());
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
return true;
}
return false;
}
);
/*
PB.registerPipelineStartEPCallback(
[](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(RemoveSecret());
});
*/
}
};
}