about summary refs log tree commit diff
path: root/instrumentation/afl-llvm-pass.so.cc
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2021-12-09 14:33:56 +0100
committervanhauser-thc <vh@thc.org>2021-12-09 14:33:56 +0100
commitdb360332c4cf92c3b90d8dfab9292763e677aebf (patch)
treeab1bb8e44a22e36d1b53646a57c10844bf4a6978 /instrumentation/afl-llvm-pass.so.cc
parent4c6d94ea5f854071277ed9729de2d4ef7d07cc84 (diff)
downloadafl++-db360332c4cf92c3b90d8dfab9292763e677aebf.tar.gz
make llvm 14-dev working. again.
Diffstat (limited to 'instrumentation/afl-llvm-pass.so.cc')
-rw-r--r--instrumentation/afl-llvm-pass.so.cc44
1 files changed, 36 insertions, 8 deletions
diff --git a/instrumentation/afl-llvm-pass.so.cc b/instrumentation/afl-llvm-pass.so.cc
index 8e22fde8..640aa4dd 100644
--- a/instrumentation/afl-llvm-pass.so.cc
+++ b/instrumentation/afl-llvm-pass.so.cc
@@ -454,7 +454,11 @@ bool AFLCoverage::runOnModule(Module &M) {
 #ifdef AFL_HAVE_VECTOR_INTRINSICS
         if (ctx_k) {
 
-          PrevCaller = IRB.CreateLoad(AFLPrevCaller);
+          PrevCaller = IRB.CreateLoad(
+  #if LLVM_VERSION_MAJOR >= 14
+              IRB.getInt32Ty(),
+  #endif
+              AFLPrevCaller);
           PrevCaller->setMetadata(M.getMDKindID("nosanitize"),
                                   MDNode::get(C, None));
           PrevCtx =
@@ -467,7 +471,11 @@ bool AFLCoverage::runOnModule(Module &M) {
 
           // load the context ID of the previous function and write to to a
           // local variable on the stack
-          LoadInst *PrevCtxLoad = IRB.CreateLoad(AFLContext);
+          LoadInst *PrevCtxLoad = IRB.CreateLoad(
+#if LLVM_VERSION_MAJOR >= 14
+              IRB.getInt32Ty(),
+#endif
+              AFLContext);
           PrevCtxLoad->setMetadata(M.getMDKindID("nosanitize"),
                                    MDNode::get(C, None));
           PrevCtx = PrevCtxLoad;
@@ -620,7 +628,11 @@ bool AFLCoverage::runOnModule(Module &M) {
 
       /* Load prev_loc */
 
-      LoadInst *PrevLoc = IRB.CreateLoad(AFLPrevLoc);
+      LoadInst *PrevLoc = IRB.CreateLoad(
+#if LLVM_VERSION_MAJOR >= 14
+          IRB.getInt32Ty(),
+#endif
+          AFLPrevLoc);
       PrevLoc->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
       Value *PrevLocTrans;
 
@@ -644,20 +656,28 @@ bool AFLCoverage::runOnModule(Module &M) {
 
       /* Load SHM pointer */
 
-      LoadInst *MapPtr = IRB.CreateLoad(AFLMapPtr);
+      LoadInst *MapPtr = IRB.CreateLoad(
+#if LLVM_VERSION_MAJOR >= 14
+          PointerType::get(Int8Ty, 0),
+#endif
+          AFLMapPtr);
       MapPtr->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
 
       Value *MapPtrIdx;
 #ifdef AFL_HAVE_VECTOR_INTRINSICS
       if (ngram_size)
         MapPtrIdx = IRB.CreateGEP(
-            MapPtr,
+            Int8Ty, MapPtr,
             IRB.CreateZExt(
                 IRB.CreateXor(PrevLocTrans, IRB.CreateZExt(CurLoc, Int32Ty)),
                 Int32Ty));
       else
 #endif
-        MapPtrIdx = IRB.CreateGEP(MapPtr, IRB.CreateXor(PrevLocTrans, CurLoc));
+        MapPtrIdx = IRB.CreateGEP(
+#if LLVM_VERSION_MAJOR >= 14
+            Int8Ty,
+#endif
+            MapPtr, IRB.CreateXor(PrevLocTrans, CurLoc));
 
       /* Update bitmap */
 
@@ -676,7 +696,11 @@ bool AFLCoverage::runOnModule(Module &M) {
 
       } else {
 
-        LoadInst *Counter = IRB.CreateLoad(MapPtrIdx);
+        LoadInst *Counter = IRB.CreateLoad(
+#if LLVM_VERSION_MAJOR >= 14
+            IRB.getInt8Ty(),
+#endif
+            MapPtrIdx);
         Counter->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
 
         Value *Incr = IRB.CreateAdd(Counter, One);
@@ -813,7 +837,11 @@ bool AFLCoverage::runOnModule(Module &M) {
         IRBuilder<> IRB(&(*it0));
 
         // load the old counter value atomically
-        LoadInst *Counter = IRB.CreateLoad(MapPtrIdx);
+        LoadInst *Counter = IRB.CreateLoad(
+  #if LLVM_VERSION_MAJOR >= 14
+        IRB.getInt8Ty(),
+  #endif
+        MapPtrIdx);
         Counter->setAlignment(llvm::Align());
         Counter->setAtomic(llvm::AtomicOrdering::Monotonic);
         Counter->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));