code cleanup

This commit is contained in:
Dominik Maier
2020-03-30 00:50:32 +02:00
parent f4844e2c0c
commit 28e5a8031c

View File

@ -151,7 +151,8 @@ uint64_t PowerOf2Ceil(unsigned in) {
#endif #endif
/* #if LLVM_VERSION_STRING >= "4.0.1" */ /* #if LLVM_VERSION_STRING >= "4.0.1" */
#if LLVM_VERSION_MAJOR >= 4 || (LLVM_VERSION_MAJOR == 4 && LLVM_VERSION_PATCH >= 1) #if LLVM_VERSION_MAJOR >= 4 || \
(LLVM_VERSION_MAJOR == 4 && LLVM_VERSION_PATCH >= 1)
#define AFL_HAVE_VECTOR_INTRINSICS 1 #define AFL_HAVE_VECTOR_INTRINSICS 1
#endif #endif
bool AFLCoverage::runOnModule(Module &M) { bool AFLCoverage::runOnModule(Module &M) {
@ -217,7 +218,8 @@ bool AFLCoverage::runOnModule(Module &M) {
if (sscanf(ngram_size_str, "%u", &ngram_size) != 1 || ngram_size < 2 || if (sscanf(ngram_size_str, "%u", &ngram_size) != 1 || ngram_size < 2 ||
ngram_size > MAX_NGRAM_SIZE) ngram_size > MAX_NGRAM_SIZE)
FATAL( FATAL(
"Bad value of AFL_NGRAM_SIZE (must be between 2 and MAX_NGRAM_SIZE (%u))", "Bad value of AFL_NGRAM_SIZE (must be between 2 and MAX_NGRAM_SIZE "
"(%u))",
MAX_NGRAM_SIZE); MAX_NGRAM_SIZE);
if (ngram_size == 1) ngram_size = 0; if (ngram_size == 1) ngram_size = 0;
@ -233,7 +235,7 @@ bool AFLCoverage::runOnModule(Module &M) {
PrevLocSize = 1; PrevLocSize = 1;
#ifdef AFL_HAVE_VECTOR_INTRINSICS #ifdef AFL_HAVE_VECTOR_INTRINSICS
uint64_t PrevLocVecSize = PowerOf2Ceil(PrevLocSize); uint64_t PrevLocVecSize = PowerOf2Ceil(PrevLocSize);
if (ngram_size) PrevLocTy = VectorType::get(IntLocTy, PrevLocVecSize); if (ngram_size) PrevLocTy = VectorType::get(IntLocTy, PrevLocVecSize);
#endif #endif
@ -247,26 +249,26 @@ bool AFLCoverage::runOnModule(Module &M) {
#ifdef AFL_HAVE_VECTOR_INTRINSICS #ifdef AFL_HAVE_VECTOR_INTRINSICS
if (ngram_size) if (ngram_size)
# ifdef __ANDROID__ #ifdef __ANDROID__
AFLPrevLoc = new GlobalVariable( AFLPrevLoc = new GlobalVariable(
M, PrevLocTy, /* isConstant */ false, GlobalValue::ExternalLinkage, M, PrevLocTy, /* isConstant */ false, GlobalValue::ExternalLinkage,
/* Initializer */ nullptr, "__afl_prev_loc"); /* Initializer */ nullptr, "__afl_prev_loc");
# else #else
AFLPrevLoc = new GlobalVariable( AFLPrevLoc = new GlobalVariable(
M, PrevLocTy, /* isConstant */ false, GlobalValue::ExternalLinkage, M, PrevLocTy, /* isConstant */ false, GlobalValue::ExternalLinkage,
/* Initializer */ nullptr, "__afl_prev_loc", /* Initializer */ nullptr, "__afl_prev_loc",
/* InsertBefore */ nullptr, GlobalVariable::GeneralDynamicTLSModel, /* InsertBefore */ nullptr, GlobalVariable::GeneralDynamicTLSModel,
/* AddressSpace */ 0, /* IsExternallyInitialized */ false); /* AddressSpace */ 0, /* IsExternallyInitialized */ false);
# endif #endif
else else
#endif #endif
#ifdef __ANDROID__ #ifdef __ANDROID__
AFLPrevLoc = new GlobalVariable( AFLPrevLoc = new GlobalVariable(
M, Int32Ty, false, GlobalValue::ExternalLinkage, 0, "__afl_prev_loc"); M, Int32Ty, false, GlobalValue::ExternalLinkage, 0, "__afl_prev_loc");
#else #else
AFLPrevLoc = new GlobalVariable( AFLPrevLoc = new GlobalVariable(
M, Int32Ty, false, GlobalValue::ExternalLinkage, 0, "__afl_prev_loc", 0, M, Int32Ty, false, GlobalValue::ExternalLinkage, 0, "__afl_prev_loc", 0,
GlobalVariable::GeneralDynamicTLSModel, 0, false); GlobalVariable::GeneralDynamicTLSModel, 0, false);
#endif #endif
#ifdef AFL_HAVE_VECTOR_INTRINSICS #ifdef AFL_HAVE_VECTOR_INTRINSICS
@ -594,6 +596,7 @@ bool AFLCoverage::runOnModule(Module &M) {
Store->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None)); Store->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
} else } else
#endif #endif
{ {