about summary refs log tree commit diff
path: root/llvm_mode/afl-llvm-pass.so.cc
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2019-11-22 11:03:45 +0000
committerDavid Carlier <devnexen@gmail.com>2019-11-22 11:03:45 +0000
commit8a2f2e17920a8501582cff72cc6fbf32b18f9d30 (patch)
treed4fa9ecf37e86a659264eeb0d5e0880e1534549a /llvm_mode/afl-llvm-pass.so.cc
parent79490e75beefdfc737129112ecbc9c74bf4a4609 (diff)
downloadafl++-8a2f2e17920a8501582cff72cc6fbf32b18f9d30.tar.gz
compiler plugins, just create const constants once.
Diffstat (limited to 'llvm_mode/afl-llvm-pass.so.cc')
-rw-r--r--llvm_mode/afl-llvm-pass.so.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm_mode/afl-llvm-pass.so.cc b/llvm_mode/afl-llvm-pass.so.cc
index 0c68136b..4ce073a5 100644
--- a/llvm_mode/afl-llvm-pass.so.cc
+++ b/llvm_mode/afl-llvm-pass.so.cc
@@ -150,6 +150,8 @@ bool AFLCoverage::runOnModule(Module &M) {
       M, Int32Ty, false, GlobalValue::ExternalLinkage, 0, "__afl_prev_loc", 0,
       GlobalVariable::GeneralDynamicTLSModel, 0, false);
 #endif
+  ConstantInt *Zero = ConstantInt::get(Int8Ty, 0);
+  ConstantInt *One = ConstantInt::get(Int8Ty, 1);
 
   /* Instrument all the things! */
 
@@ -287,7 +289,7 @@ bool AFLCoverage::runOnModule(Module &M) {
       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 !=
@@ -331,7 +333,7 @@ bool AFLCoverage::runOnModule(Module &M) {
         */
         // this is the solution we choose because llvm9 should do the right
         // thing here
-        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);
 /*