diff options
author | van Hauser <vh@thc.org> | 2019-11-22 13:30:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-22 13:30:47 +0100 |
commit | ccb156c704f3463fa0e1cf19f7afed1293b294bf (patch) | |
tree | d4fa9ecf37e86a659264eeb0d5e0880e1534549a /llvm_mode/LLVMInsTrim.so.cc | |
parent | 79490e75beefdfc737129112ecbc9c74bf4a4609 (diff) | |
parent | 8a2f2e17920a8501582cff72cc6fbf32b18f9d30 (diff) | |
download | afl++-ccb156c704f3463fa0e1cf19f7afed1293b294bf.tar.gz |
Merge pull request #114 from devnexen/cmp_plugin_create_constants_once
compiler plugins, just create const constants once.
Diffstat (limited to 'llvm_mode/LLVMInsTrim.so.cc')
-rw-r--r-- | llvm_mode/LLVMInsTrim.so.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm_mode/LLVMInsTrim.so.cc b/llvm_mode/LLVMInsTrim.so.cc index 89738812..f723a0fe 100644 --- a/llvm_mode/LLVMInsTrim.so.cc +++ b/llvm_mode/LLVMInsTrim.so.cc @@ -146,6 +146,9 @@ struct InsTrim : public ModulePass { M, Int32Ty, false, GlobalValue::ExternalLinkage, 0, "__afl_prev_loc", 0, GlobalVariable::GeneralDynamicTLSModel, 0, false); + ConstantInt *Zero = ConstantInt::get(Int8Ty, 0); + ConstantInt *One = ConstantInt::get(Int8Ty, 1); + u64 total_rs = 0; u64 total_hs = 0; @@ -368,7 +371,7 @@ struct InsTrim : public ModulePass { LoadInst *Counter = IRB.CreateLoad(MapPtrIdx); Counter->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None)); - Value *Incr = IRB.CreateAdd(Counter, ConstantInt::get(Int8Ty, 1)); + Value *Incr = IRB.CreateAdd(Counter, One); #if LLVM_VERSION_MAJOR < 9 if (neverZero_counters_str != @@ -390,7 +393,7 @@ struct InsTrim : public ModulePass { * Counter + 1 -> {Counter, OverflowFlag} * Counter + OverflowFlag -> Counter */ - auto cf = IRB.CreateICmpEQ(Incr, ConstantInt::get(Int8Ty, 0)); + auto cf = IRB.CreateICmpEQ(Incr, Zero); auto carry = IRB.CreateZExt(cf, Int8Ty); Incr = IRB.CreateAdd(Incr, carry); |