fix float splitting if not on a tty
MODIFY
llvm_mode/split-compares-pass.so.cc
llvm_mode/split-compares-pass.so.cc
@@ -1248,6 +1248,7 @@ size_t SplitComparesTransform::splitIntCompares(Module &M, unsigned bitw) {
bool SplitComparesTransform::runOnModule(Module &M) {
int bitw = 64;
+ size_t count;
char *bitw_env = getenv("AFL_LLVM_LAF_SPLIT_COMPARES_BITW");
if (!bitw_env) bitw_env = getenv("LAF_SPLIT_COMPARES_BITW");
@@ -1261,18 +1262,26 @@ bool SplitComparesTransform::runOnModule(Module &M) {
errs() << "Split-compare-pass by laf.intel@gmail.com, extended by "
"heiko@hexco.de\n";
+ } else {
+
+ be_quiet = 1;
+
+ }
+
if (enableFPSplit) {
- errs() << "Split-floatingpoint-compare-pass: " << splitFPCompares(M)
+ count = splitFPCompares(M);
+
+ if (!be_quiet) {
+
+ errs() << "Split-floatingpoint-compare-pass: " << count
<< " FP comparisons splitted\n";
}
- } else
+ simplifyFPCompares(M);
- be_quiet = 1;
-
- if (enableFPSplit) simplifyFPCompares(M);
+ }
simplifyCompares(M);
@@ -1281,9 +1290,10 @@ bool SplitComparesTransform::runOnModule(Module &M) {
switch (bitw) {
case 64:
+ count = splitIntCompares(M, bitw);
if (!be_quiet)
- errs() << "Split-integer-compare-pass " << bitw
- << "bit: " << splitIntCompares(M, bitw) << " splitted\n";
+ errs() << "Split-integer-compare-pass " << bitw << "bit: " << count
+ << " splitted\n";
bitw >>= 1;
#if LLVM_VERSION_MAJOR > 3 || \
@@ -1291,9 +1301,10 @@ bool SplitComparesTransform::runOnModule(Module &M) {
[[clang::fallthrough]]; /*FALLTHRU*/ /* FALLTHROUGH */
#endif
case 32:
+ count = splitIntCompares(M, bitw);
if (!be_quiet)
- errs() << "Split-integer-compare-pass " << bitw
- << "bit: " << splitIntCompares(M, bitw) << " splitted\n";
+ errs() << "Split-integer-compare-pass " << bitw << "bit: " << count
+ << " splitted\n";
bitw >>= 1;
#if LLVM_VERSION_MAJOR > 3 || \
@@ -1301,9 +1312,10 @@ bool SplitComparesTransform::runOnModule(Module &M) {
[[clang::fallthrough]]; /*FALLTHRU*/ /* FALLTHROUGH */
#endif
case 16:
+ count = splitIntCompares(M, bitw);
if (!be_quiet)
- errs() << "Split-integer-compare-pass " << bitw
- << "bit: " << splitIntCompares(M, bitw) << " splitted\n";
+ errs() << "Split-integer-compare-pass " << bitw << "bit: " << count
+ << " splitted\n";
bitw >>= 1;
break;

MODIFY
test/test-floatingpoint.c
test/test-floatingpoint.c
@@ -15,7 +15,7 @@ int main(void) {
while (__AFL_LOOP(INT_MAX)) {
int len = __AFL_FUZZ_TESTCASE_LEN;
- if (len != sizeof(float)) return 1;
+ if (len < sizeof(float)) return 1;
/* 15 + 1/2 = 15.5 */
/* 15 + 1/2 + 1/8 = 15.625 */

MODIFY
test/test.sh
test/test.sh
@@ -389,7 +389,7 @@ test -e ../afl-clang-fast -a -e ../split-switches-pass.so && {
CODE=1
}
rm -f test-compcov.compcov test.out
- AFL_LLVM_INSTRUMENT=AFL AFL_LLVM_LAF_SPLIT_FLOATS=1 ../afl-clang-fast -o test-floatingpoint test-floatingpoint.c >errors
+ AFL_LLVM_INSTRUMENT=AFL AFL_LLVM_LAF_SPLIT_FLOATS=1 ../afl-clang-fast -o test-floatingpoint test-floatingpoint.c >errors 2>&1
test -e test-floatingpoint && {
mkdir -p in
echo ZZZZ > in/in

fix float splitting if not on a tty