mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-13 18:48:08 +00:00
transform cmplog-instructions pass to new pass manager
This commit is contained in:
@ -28,11 +28,16 @@
|
|||||||
#include "llvm/Config/llvm-config.h"
|
#include "llvm/Config/llvm-config.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/IR/IRBuilder.h"
|
#include "llvm/IR/IRBuilder.h"
|
||||||
#include "llvm/IR/LegacyPassManager.h"
|
|
||||||
#include "llvm/IR/Module.h"
|
#include "llvm/IR/Module.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
#if LLVM_MAJOR >= 11
|
||||||
|
// #include "llvm/Passes/PassPlugin.h"
|
||||||
|
// #include "llvm/Passes/PassBuilder.h"
|
||||||
|
#include "llvm/IR/PassManager.h"
|
||||||
|
#else
|
||||||
|
#include "llvm/IR/LegacyPassManager.h"
|
||||||
|
#endif
|
||||||
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
|
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Analysis/ValueTracking.h"
|
#include "llvm/Analysis/ValueTracking.h"
|
||||||
@ -54,6 +59,15 @@ using namespace llvm;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
#if LLVM_MAJOR >= 11 /* use new pass manager */
|
||||||
|
class CmpLogInstructions : public PassInfoMixin<CmpLogInstructions> {
|
||||||
|
public:
|
||||||
|
CmpLogInstructions() {
|
||||||
|
|
||||||
|
initInstrumentList();
|
||||||
|
|
||||||
|
}
|
||||||
|
#else
|
||||||
class CmpLogInstructions : public ModulePass {
|
class CmpLogInstructions : public ModulePass {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -63,7 +77,11 @@ class CmpLogInstructions : public ModulePass {
|
|||||||
initInstrumentList();
|
initInstrumentList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LLVM_MAJOR >= 11 /* use new pass manager */
|
||||||
|
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
|
||||||
|
#else
|
||||||
bool runOnModule(Module &M) override;
|
bool runOnModule(Module &M) override;
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 4
|
#if LLVM_VERSION_MAJOR < 4
|
||||||
@ -76,6 +94,7 @@ class CmpLogInstructions : public ModulePass {
|
|||||||
return "cmplog instructions";
|
return "cmplog instructions";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool hookInstrs(Module &M);
|
bool hookInstrs(Module &M);
|
||||||
@ -84,7 +103,9 @@ class CmpLogInstructions : public ModulePass {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
#if LLVM_MAJOR <= 10 /* use old pass manager */
|
||||||
char CmpLogInstructions::ID = 0;
|
char CmpLogInstructions::ID = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
template <class Iterator>
|
template <class Iterator>
|
||||||
Iterator Unique(Iterator first, Iterator last) {
|
Iterator Unique(Iterator first, Iterator last) {
|
||||||
@ -567,7 +588,12 @@ bool CmpLogInstructions::hookInstrs(Module &M) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LLVM_MAJOR >= 11 /* use new pass manager */
|
||||||
|
PreservedAnalyses CmpLogInstructions::run(Module & M,
|
||||||
|
ModuleAnalysisManager &MAM) {
|
||||||
|
#else
|
||||||
bool CmpLogInstructions::runOnModule(Module &M) {
|
bool CmpLogInstructions::runOnModule(Module &M) {
|
||||||
|
#endif
|
||||||
|
|
||||||
if (getenv("AFL_QUIET") == NULL)
|
if (getenv("AFL_QUIET") == NULL)
|
||||||
printf("Running cmplog-instructions-pass by andreafioraldi@gmail.com\n");
|
printf("Running cmplog-instructions-pass by andreafioraldi@gmail.com\n");
|
||||||
@ -576,10 +602,15 @@ bool CmpLogInstructions::runOnModule(Module &M) {
|
|||||||
hookInstrs(M);
|
hookInstrs(M);
|
||||||
verifyModule(M);
|
verifyModule(M);
|
||||||
|
|
||||||
|
#if LLVM_MAJOR >= 11 /* use new pass manager */
|
||||||
|
return PreservedAnalyses::all();
|
||||||
|
#else
|
||||||
return true;
|
return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LLVM_MAJOR < 11 /* use old pass manager */
|
||||||
static void registerCmpLogInstructionsPass(const PassManagerBuilder &,
|
static void registerCmpLogInstructionsPass(const PassManagerBuilder &,
|
||||||
legacy::PassManagerBase &PM) {
|
legacy::PassManagerBase &PM) {
|
||||||
|
|
||||||
@ -599,4 +630,4 @@ static RegisterStandardPasses RegisterCmpLogInstructionsPassLTO(
|
|||||||
PassManagerBuilder::EP_FullLinkTimeOptimizationLast,
|
PassManagerBuilder::EP_FullLinkTimeOptimizationLast,
|
||||||
registerCmpLogInstructionsPass);
|
registerCmpLogInstructionsPass);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
11
src/afl-cc.c
11
src/afl-cc.c
@ -573,10 +573,6 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LLVM_MAJOR >= 13
|
|
||||||
// fuck you llvm 13
|
|
||||||
cc_params[cc_par_cnt++] = "-fno-experimental-new-pass-manager";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (lto_mode && !have_c) {
|
if (lto_mode && !have_c) {
|
||||||
|
|
||||||
@ -616,6 +612,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
cc_params[cc_par_cnt++] = "-fno-experimental-new-pass-manager";
|
||||||
cc_params[cc_par_cnt++] = "-Xclang";
|
cc_params[cc_par_cnt++] = "-Xclang";
|
||||||
cc_params[cc_par_cnt++] = "-load";
|
cc_params[cc_par_cnt++] = "-load";
|
||||||
cc_params[cc_par_cnt++] = "-Xclang";
|
cc_params[cc_par_cnt++] = "-Xclang";
|
||||||
@ -674,11 +671,17 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
#if LLVM_MAJOR >= 11
|
||||||
|
cc_params[cc_par_cnt++] = "-fexperimental-new-pass-manager";
|
||||||
|
cc_params[cc_par_cnt++] =
|
||||||
|
alloc_printf("-fpass-plugin=%s/cmplog-instructions-pass.so", obj_path);
|
||||||
|
#else
|
||||||
cc_params[cc_par_cnt++] = "-Xclang";
|
cc_params[cc_par_cnt++] = "-Xclang";
|
||||||
cc_params[cc_par_cnt++] = "-load";
|
cc_params[cc_par_cnt++] = "-load";
|
||||||
cc_params[cc_par_cnt++] = "-Xclang";
|
cc_params[cc_par_cnt++] = "-Xclang";
|
||||||
cc_params[cc_par_cnt++] =
|
cc_params[cc_par_cnt++] =
|
||||||
alloc_printf("%s/cmplog-instructions-pass.so", obj_path);
|
alloc_printf("%s/cmplog-instructions-pass.so", obj_path);
|
||||||
|
#endif
|
||||||
|
|
||||||
cc_params[cc_par_cnt++] = "-Xclang";
|
cc_params[cc_par_cnt++] = "-Xclang";
|
||||||
cc_params[cc_par_cnt++] = "-load";
|
cc_params[cc_par_cnt++] = "-load";
|
||||||
|
Reference in New Issue
Block a user