about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2023-02-20 15:43:54 +0100
committervanhauser-thc <vh@thc.org>2023-02-20 15:43:54 +0100
commitb786558dea5fd5dca471a0e36a8b420ff6a65846 (patch)
treef7055992a36cc143a00fab61dea7f652cc174432
parentebaac23a514cd3950d4a6cb597bd921e13ab9baa (diff)
downloadafl++-b786558dea5fd5dca471a0e36a8b420ff6a65846.tar.gz
Revert "LLVM cmplog factoring custom Instruction iterator with added restriction"
This reverts commit 8bc3fa1df286aac46a0a724f64e2e07010d2497e.
-rw-r--r--instrumentation/afl-llvm-common.cc18
-rw-r--r--instrumentation/afl-llvm-common.h2
-rw-r--r--instrumentation/cmplog-instructions-pass.cc15
-rw-r--r--instrumentation/cmplog-switches-pass.cc15
4 files changed, 30 insertions, 20 deletions
diff --git a/instrumentation/afl-llvm-common.cc b/instrumentation/afl-llvm-common.cc
index b50269fe..dc34d191 100644
--- a/instrumentation/afl-llvm-common.cc
+++ b/instrumentation/afl-llvm-common.cc
@@ -582,24 +582,6 @@ bool isInInstrumentList(llvm::Function *F, std::string Filename) {
 
 }
 
-template <class Iterator>
-Iterator Unique(Iterator first, Iterator last) {
-  static_assert(std::is_trivially_copyable<
-        typename std::iterator_traits<Iterator>
-        >::value_type, "Invalid underlying type");
-
-  while (first != last) {
-
-    Iterator next(first);
-    last = std::remove(++next, last, *first);
-    first = next;
-
-  }
-
-  return last;
-
-}
-
 // Calculate the number of average collisions that would occur if all
 // location IDs would be assigned randomly (like normal afl/afl++).
 // This uses the "balls in bins" algorithm.
diff --git a/instrumentation/afl-llvm-common.h b/instrumentation/afl-llvm-common.h
index 8b8dc756..0112c325 100644
--- a/instrumentation/afl-llvm-common.h
+++ b/instrumentation/afl-llvm-common.h
@@ -9,7 +9,6 @@
 #include <string>
 #include <fstream>
 #include <optional>
-#include <type_traits>
 #include <sys/time.h>
 
 #include "llvm/Config/llvm-config.h"
@@ -54,7 +53,6 @@ void  initInstrumentList();
 bool  isInInstrumentList(llvm::Function *F, std::string Filename);
 unsigned long long int calculateCollisions(uint32_t edges);
 void                   scanForDangerousFunctions(llvm::Module *M);
-template<class Iterator> Iterator Unique(Iterator, Iterator);
 
 #ifndef IS_EXTERN
   #define IS_EXTERN
diff --git a/instrumentation/cmplog-instructions-pass.cc b/instrumentation/cmplog-instructions-pass.cc
index c6fd7c56..bca1f927 100644
--- a/instrumentation/cmplog-instructions-pass.cc
+++ b/instrumentation/cmplog-instructions-pass.cc
@@ -138,6 +138,21 @@ llvmGetPassPluginInfo() {
 char CmpLogInstructions::ID = 0;
 #endif
 
+template <class Iterator>
+Iterator Unique(Iterator first, Iterator last) {
+
+  while (first != last) {
+
+    Iterator next(first);
+    last = std::remove(++next, last, *first);
+    first = next;
+
+  }
+
+  return last;
+
+}
+
 bool CmpLogInstructions::hookInstrs(Module &M) {
 
   std::vector<Instruction *> icomps;
diff --git a/instrumentation/cmplog-switches-pass.cc b/instrumentation/cmplog-switches-pass.cc
index f4a9fbd7..cd0ae76d 100644
--- a/instrumentation/cmplog-switches-pass.cc
+++ b/instrumentation/cmplog-switches-pass.cc
@@ -131,6 +131,21 @@ llvmGetPassPluginInfo() {
 char CmplogSwitches::ID = 0;
 #endif
 
+template <class Iterator>
+Iterator Unique(Iterator first, Iterator last) {
+
+  while (first != last) {
+
+    Iterator next(first);
+    last = std::remove(++next, last, *first);
+    first = next;
+
+  }
+
+  return last;
+
+}
+
 bool CmplogSwitches::hookInstrs(Module &M) {
 
   std::vector<SwitchInst *> switches;