minor cmplog fix
diff --git a/docs/Changelog.md b/docs/Changelog.md
index 71ef4c2..477498d 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -48,6 +48,7 @@
support (less performant than our own), GCC for old afl-gcc and
CLANG for old afl-clang
- fixed a potential crash in the LAF feature
+ - workaround for llvm bitcast lto bug
- workaround for llvm 13
- qemuafl
- QASan (address sanitizer for Qemu) ported to qemuafl!
diff --git a/instrumentation/cmplog-instructions-pass.cc b/instrumentation/cmplog-instructions-pass.cc
index 50ade9f..dbca9af 100644
--- a/instrumentation/cmplog-instructions-pass.cc
+++ b/instrumentation/cmplog-instructions-pass.cc
@@ -266,13 +266,20 @@
unsigned int max_size = Val->getType()->getIntegerBitWidth(), cast_size;
unsigned char do_cast = 0;
- if (!SI->getNumCases() || max_size < 16 || max_size % 8) {
+ if (!SI->getNumCases() || max_size < 16) {
// if (!be_quiet) errs() << "skip trivial switch..\n";
continue;
}
+ if (max_size % 8) {
+
+ max_size = (((max_size / 8) + 1) * 8);
+ do_cast = 1;
+
+ }
+
IRBuilder<> IRB(SI->getParent());
IRB.SetInsertPoint(SI);
@@ -310,8 +317,10 @@
Value *CompareTo = Val;
if (do_cast) {
+
CompareTo =
IRB.CreateIntCast(CompareTo, IntegerType::get(C, cast_size), false);
+
}
for (SwitchInst::CaseIt i = SI->case_begin(), e = SI->case_end(); i != e;
@@ -331,8 +340,10 @@
Value *new_param = cint;
if (do_cast) {
+
new_param =
IRB.CreateIntCast(cint, IntegerType::get(C, cast_size), false);
+
}
if (new_param) {
@@ -490,7 +501,14 @@
}
- if (!max_size || max_size % 8 || max_size < 16) { continue; }
+ if (!max_size || max_size < 16) { continue; }
+
+ if (max_size % 8) {
+
+ max_size = (((max_size / 8) + 1) * 8);
+ do_cast = 1;
+
+ }
if (max_size > 128) {