From db360332c4cf92c3b90d8dfab9292763e677aebf Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Thu, 9 Dec 2021 14:33:56 +0100 Subject: make llvm 14-dev working. again. --- test/test-llvm-lto.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/test-llvm-lto.sh b/test/test-llvm-lto.sh index 3e762acf..9ff2ec10 100755 --- a/test/test-llvm-lto.sh +++ b/test/test-llvm-lto.sh @@ -3,7 +3,7 @@ . ./test-pre.sh $ECHO "$BLUE[*] Testing: LTO llvm_mode" -test -e ../afl-clang-lto -a -e ../afl-llvm-lto-instrumentation.so && { +test -e ../afl-clang-lto -a -e ../SanitizerCoverageLTO.so && { # on FreeBSD need to set AFL_CC test `uname -s` = 'FreeBSD' && { if type clang >/dev/null; then -- cgit 1.4.1 From 0648772967249f0a8a693fc3f2617ab46467c5b0 Mon Sep 17 00:00:00 2001 From: hexcoder- Date: Fri, 10 Dec 2021 23:09:07 +0100 Subject: additional test cases for floating point comparison splitting pass --- test/test-fpExtra.sh | 39 +++++++++++++ test/test-fp_Infcases.c | 124 ++++++++++++++++++++++++++++++++++++++++++ test/test-fp_NaNcases.c | 86 +++++++++++++++++++++++++++++ test/test-fp_minusZerocases.c | 35 ++++++++++++ 4 files changed, 284 insertions(+) create mode 100755 test/test-fpExtra.sh create mode 100644 test/test-fp_Infcases.c create mode 100644 test/test-fp_NaNcases.c create mode 100644 test/test-fp_minusZerocases.c (limited to 'test') diff --git a/test/test-fpExtra.sh b/test/test-fpExtra.sh new file mode 100755 index 00000000..aecc6258 --- /dev/null +++ b/test/test-fpExtra.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +. ./test-pre.sh + +test -e ../afl-clang-fast -a -e ../split-switches-pass.so && { + $ECHO "$GREY[*] llvm_mode laf-intel/compcov testing splitting floating point types with Nan, infinity, minusZero" + for testcase in ./test-fp_minusZerocases.c ./test-fp_Infcases.c ./test-fp_NaNcases.c; do + #for testcase in ./test-fp_cases.c ./test-fp_Infcases.c ./test-fp_NaNcases.c ./test-fp_minusZerocases.c ; do + for I in float double "long double"; do + #for I in double; do + for BITS in 64 32 16 8; do + #for BITS in 64; do + bin="$testcase-split-$I-$BITS.compcov" +#AFL_DONT_OPTIMIZE=1 AFL_LLVM_INSTRUMENT=AFL AFL_DEBUG=1 AFL_LLVM_LAF_SPLIT_COMPARES_BITW=$BITS AFL_LLVM_LAF_SPLIT_COMPARES=1 AFL_LLVM_LAF_SPLIT_FLOATS=1 ../afl-clang-fast -DFLOAT_TYPE="$I" -S "$testcase" +#AFL_DONT_OPTIMIZE=1 AFL_LLVM_INSTRUMENT=AFL AFL_DEBUG=1 AFL_LLVM_LAF_SPLIT_COMPARES_BITW=$BITS AFL_LLVM_LAF_SPLIT_COMPARES=1 AFL_LLVM_LAF_SPLIT_FLOATS=1 ../afl-clang-fast -DFLOAT_TYPE="$I" -S -emit-llvm "$testcase" +AFL_DONT_OPTIMIZE=1 AFL_LLVM_INSTRUMENT=AFL AFL_DEBUG=1 AFL_LLVM_LAF_SPLIT_COMPARES_BITW=$BITS AFL_LLVM_LAF_SPLIT_COMPARES=1 AFL_LLVM_LAF_SPLIT_FLOATS=1 ../afl-clang-fast -DFLOAT_TYPE="$I" -o "$bin" "$testcase" > test.out 2>&1; + if ! test -e "$bin"; then + cat test.out + $ECHO "$RED[!] llvm_mode laf-intel/compcov float splitting failed! ($testcase with type $I split to $BITS)!"; + CODE=1 + break + fi + if ! "$bin"; then + $ECHO "$RED[!] llvm_mode laf-intel/compcov float splitting resulted in miscompilation (type $I split to $BITS)!"; + CODE=1 + break + fi + rm -f "$bin" test.out || true + done + done + done + rm -f test-fp_cases*.compcov test.out + +} || { + $ECHO "$YELLOW[-] llvm_mode not compiled, cannot test" + INCOMPLETE=1 +} + +. ./test-post.sh diff --git a/test/test-fp_Infcases.c b/test/test-fp_Infcases.c new file mode 100644 index 00000000..88a89ead --- /dev/null +++ b/test/test-fp_Infcases.c @@ -0,0 +1,124 @@ +/* test cases for floating point comparison transformations + * compile with -DFLOAT_TYPE=float + * or -DFLOAT_TYPE=double + * or -DFLOAT_TYPE="long double" + */ + +#include +#define _GNU_SOURCE +#include /* for NaNs and infinity values */ + +int main() { + + volatile FLOAT_TYPE a, b; + +#ifdef INFINITY + FLOAT_TYPE inf = (FLOAT_TYPE) INFINITY; +#else + FLOAT_TYPE inf = 1.0 / 0.0; /* produces infinity */ +#endif + FLOAT_TYPE negZero = 1.0 / -inf; + FLOAT_TYPE posZero = 0.0; + + /* plus infinity */ + a = (1.0 / 0.0); /* positive infinity */ + b = (1.0 / 0.0); /* positive infinity */ + assert(!(a < b)); + assert((a <= b)); + assert(!(a > b)); + assert((a >= b)); + assert(!(a != b)); + assert((a == b)); + + b = -(1.0 / 0.0); /* negative infinity */ + assert(!(a < b)); + assert(!(a <= b)); + assert((a > b)); + assert((a >= b)); + assert((a != b)); + assert(!(a == b)); + + b = 1.0 / -(1.0 / 0.0); /* negative 0 */ + assert(!(a < b)); + assert(!(a <= b)); + assert((a > b)); + assert((a >= b)); + assert((a != b)); + assert(!(a == b)); + + b = 0.0; /* positive 0 */ + assert(!(a < b)); + assert(!(a <= b)); + assert((a > b)); + assert((a >= b)); + assert((a != b)); + assert(!(a == b)); + + b = -42.0; + assert(!(a < b)); + assert(!(a <= b)); + assert((a > b)); + assert((a >= b)); + assert((a != b)); + assert(!(a == b)); + + b = 42.0; + assert(!(a < b)); + assert(!(a <= b)); + assert((a > b)); + assert((a >= b)); + assert((a != b)); + assert(!(a == b)); + + /* negative infinity */ + a = -(1.0 / 0.0); + b = (1.0 / 0.0); /* positive infinity */ + assert((a < b)); + assert((a <= b)); + assert(!(a > b)); + assert(!(a >= b)); + assert((a != b)); + assert(!(a == b)); + + b = -(1.0 / 0.0); /* negative infinity */ + assert(!(a < b)); + assert((a <= b)); + assert(!(a > b)); + assert((a >= b)); + assert(!(a != b)); + assert((a == b)); + + b = 1.0 / -(1.0 / 0.0); /* negative 0 */ + assert((a < b)); + assert((a <= b)); + assert(!(a > b)); + assert(!(a >= b)); + assert((a != b)); + assert(!(a == b)); + + b = 0.0; /* positive 0 */ + assert((a < b)); + assert((a <= b)); + assert(!(a > b)); + assert(!(a >= b)); + assert((a != b)); + assert(!(a == b)); + + b = -42.0; + assert((a < b)); + assert((a <= b)); + assert(!(a > b)); + assert(!(a >= b)); + assert((a != b)); + assert(!(a == b)); + + b = 42.0; + assert((a < b)); + assert((a <= b)); + assert(!(a > b)); + assert(!(a >= b)); + assert((a != b)); + assert(!(a == b)); + +} + diff --git a/test/test-fp_NaNcases.c b/test/test-fp_NaNcases.c new file mode 100644 index 00000000..78d32711 --- /dev/null +++ b/test/test-fp_NaNcases.c @@ -0,0 +1,86 @@ +/* test cases for floating point comparison transformations + * compile with -DFLOAT_TYPE=float + * or -DFLOAT_TYPE=double + * or -DFLOAT_TYPE="long double" + */ + +#include +#define _GNU_SOURCE +#include /* for NaNs and infinity values */ + +int main() { + + volatile FLOAT_TYPE a, b; + + /* NaN */ +#ifdef NAN + a = (FLOAT_TYPE) NAN; /* produces NaN */ +#else + a = 0.0 / 0.0; /* produces NaN */ +#endif +#ifdef INFINITY + FLOAT_TYPE inf = (FLOAT_TYPE) INFINITY; +#else + FLOAT_TYPE inf = 1.0 / 0.0; /* produces infinity */ +#endif + FLOAT_TYPE negZero = 1.0 / -inf; + FLOAT_TYPE posZero = 0.0; + b = a; + + assert(!(a < b)); + assert(!(a <= b)); + assert(!(a > b)); + assert(!(a >= b)); + assert((a != b)); + assert(!(a == b)); + + b = 0.0; + assert(!(a < b)); + assert(!(a <= b)); + assert(!(a > b)); + assert(!(a >= b)); + assert((a != b)); + assert(!(a == b)); + + b = 1.0 / -(1.0 / 0.0); /* negative 0 */ + assert(!(a < b)); + assert(!(a <= b)); + assert(!(a > b)); + assert(!(a >= b)); + assert((a != b)); + assert(!(a == b)); + + b = 42.0; + assert(!(a < b)); + assert(!(a <= b)); + assert(!(a > b)); + assert(!(a >= b)); + assert((a != b)); + assert(!(a == b)); + + b = -42.0; + assert(!(a < b)); + assert(!(a <= b)); + assert(!(a > b)); + assert(!(a >= b)); + assert((a != b)); + assert(!(a == b)); + + b = (1.0 / 0.0); /* positive infinity */ + assert(!(a < b)); + assert(!(a <= b)); + assert(!(a > b)); + assert(!(a >= b)); + assert((a != b)); + assert(!(a == b)); + + b = -(1.0 / 0.0); /* negative infinity */ + assert(!(a < b)); + assert(!(a <= b)); + assert(!(a > b)); + assert(!(a >= b)); + assert((a != b)); + assert(!(a == b)); + +} + diff --git a/test/test-fp_minusZerocases.c b/test/test-fp_minusZerocases.c new file mode 100644 index 00000000..00beef2e --- /dev/null +++ b/test/test-fp_minusZerocases.c @@ -0,0 +1,35 @@ +/* test cases for floating point comparison transformations + * compile with -DFLOAT_TYPE=float + * or -DFLOAT_TYPE=double + * or -DFLOAT_TYPE="long double" + */ + +#include +#define _GNU_SOURCE +#include /* for NaNs and infinity values */ + +int main() { + + volatile FLOAT_TYPE a, b; + + /* negative zero */ + a = 1.0 / -(1.0 / 0.0); /* negative 0 */ + b = 0.0; /* positive 0 */ + assert(!(a < b)); + assert((a <= b)); + assert(!(a > b)); + assert((a >= b)); + assert(!(a != b)); + assert((a == b)); + + a = 1.0 / -(1.0 / 0.0); /* negative 0 */ + b = 1.0 / -(1.0 / 0.0); /* negative 0 */ + assert(!(a < b)); + assert((a <= b)); + assert(!(a > b)); + assert((a >= b)); + assert(!(a != b)); + assert((a == b)); + +} + -- cgit 1.4.1 From 5b9397f3dda38df3f63bd31e4fb5f8ad64d9f271 Mon Sep 17 00:00:00 2001 From: yuawn Date: Sat, 11 Dec 2021 10:20:40 +0000 Subject: code format --- include/xxhash.h | 174 +++++++++++++++--------------- instrumentation/split-compares-pass.so.cc | 97 +++++++++-------- test/test-cmplog.c | 17 ++- test/test-fp_Infcases.c | 26 ++--- test/test-fp_NaNcases.c | 16 +-- test/test-fp_minusZerocases.c | 10 +- utils/libtokencap/libtokencap.so.c | 8 +- 7 files changed, 185 insertions(+), 163 deletions(-) (limited to 'test') diff --git a/include/xxhash.h b/include/xxhash.h index 0ca2b852..388cc552 100644 --- a/include/xxhash.h +++ b/include/xxhash.h @@ -1010,7 +1010,7 @@ XXH128_hashFromCanonical(const XXH128_canonical_t *src); * These declarations should only be used with static linking. * Never use them in association with dynamic linking! ***************************************************************************** -*/ + */ /* * These definitions are only present to allow static allocation @@ -1435,9 +1435,9 @@ XXH_PUBLIC_API XXH128_hash_t XXH128(const void *data, size_t len, #define XXH_OLD_NAMES #undef XXH_OLD_NAMES /* don't actually use, it is ugly. */ #endif /* XXH_DOXYGEN */ -/*! - * @} - */ + /*! + * @} + */ #ifndef XXH_FORCE_MEMORY_ACCESS /* can be defined externally, on command \ line for example */ @@ -1601,6 +1601,7 @@ static void *XXH_memcpy(void *dest, const void *src, size_t size) { static_assert((c), m); \ \ } while (0) + #elif defined(__cplusplus) && (__cplusplus >= 201103L) /* C++11 */ #define XXH_STATIC_ASSERT_WITH_MESSAGE(c, m) \ do { \ @@ -1608,6 +1609,7 @@ static void *XXH_memcpy(void *dest, const void *src, size_t size) { static_assert((c), m); \ \ } while (0) + #else #define XXH_STATIC_ASSERT_WITH_MESSAGE(c, m) \ do { \ @@ -1619,6 +1621,7 @@ static void *XXH_memcpy(void *dest, const void *src, size_t size) { }; \ \ } while (0) + #endif #define XXH_STATIC_ASSERT(c) XXH_STATIC_ASSERT_WITH_MESSAGE((c), #c) #endif @@ -1830,8 +1833,8 @@ static int XXH_isLittleEndian(void) { return one.c[0]; } -\ - #define XXH_CPU_LITTLE_ENDIAN XXH_isLittleEndian() + +#define XXH_CPU_LITTLE_ENDIAN XXH_isLittleEndian() #endif #endif @@ -2096,13 +2099,14 @@ static xxh_u32 XXH32_avalanche(xxh_u32 h32) { static xxh_u32 XXH32_finalize(xxh_u32 h32, const xxh_u8 *ptr, size_t len, XXH_alignment align) { \ - #define XXH_PROCESS1 \ - do { \ - \ - h32 += (*ptr++) * XXH_PRIME32_5; \ - h32 = XXH_rotl32(h32, 11) * XXH_PRIME32_1; \ - \ - } while (0) + #define XXH_PROCESS1 do { + + h32 += (*ptr++) * XXH_PRIME32_5; + h32 = XXH_rotl32(h32, 11) * XXH_PRIME32_1; + + } + + while (0) #define XXH_PROCESS4 \ do { \ @@ -2113,91 +2117,91 @@ static xxh_u32 XXH32_finalize(xxh_u32 h32, const xxh_u8 *ptr, size_t len, \ } while (0) - /* Compact rerolled version */ - if (XXH_REROLL) { - - len &= 15; - while (len >= 4) { + /* Compact rerolled version */ + if (XXH_REROLL) { - XXH_PROCESS4; - len -= 4; + len &= 15; + while (len >= 4) { - } - - while (len > 0) { + XXH_PROCESS4; + len -= 4; - XXH_PROCESS1; - --len; + } - } + while (len > 0) { - return XXH32_avalanche(h32); + XXH_PROCESS1; + --len; - } else { + } - switch (len & 15) /* or switch(bEnd - p) */ { + return XXH32_avalanche(h32); - case 12: - XXH_PROCESS4; - XXH_FALLTHROUGH; - case 8: - XXH_PROCESS4; - XXH_FALLTHROUGH; - case 4: - XXH_PROCESS4; - return XXH32_avalanche(h32); + } else { - case 13: - XXH_PROCESS4; - XXH_FALLTHROUGH; - case 9: - XXH_PROCESS4; - XXH_FALLTHROUGH; - case 5: - XXH_PROCESS4; - XXH_PROCESS1; - return XXH32_avalanche(h32); + switch (len & 15) /* or switch(bEnd - p) */ { + + case 12: + XXH_PROCESS4; + XXH_FALLTHROUGH; + case 8: + XXH_PROCESS4; + XXH_FALLTHROUGH; + case 4: + XXH_PROCESS4; + return XXH32_avalanche(h32); + + case 13: + XXH_PROCESS4; + XXH_FALLTHROUGH; + case 9: + XXH_PROCESS4; + XXH_FALLTHROUGH; + case 5: + XXH_PROCESS4; + XXH_PROCESS1; + return XXH32_avalanche(h32); + + case 14: + XXH_PROCESS4; + XXH_FALLTHROUGH; + case 10: + XXH_PROCESS4; + XXH_FALLTHROUGH; + case 6: + XXH_PROCESS4; + XXH_PROCESS1; + XXH_PROCESS1; + return XXH32_avalanche(h32); + + case 15: + XXH_PROCESS4; + XXH_FALLTHROUGH; + case 11: + XXH_PROCESS4; + XXH_FALLTHROUGH; + case 7: + XXH_PROCESS4; + XXH_FALLTHROUGH; + case 3: + XXH_PROCESS1; + XXH_FALLTHROUGH; + case 2: + XXH_PROCESS1; + XXH_FALLTHROUGH; + case 1: + XXH_PROCESS1; + XXH_FALLTHROUGH; + case 0: + return XXH32_avalanche(h32); - case 14: - XXH_PROCESS4; - XXH_FALLTHROUGH; - case 10: - XXH_PROCESS4; - XXH_FALLTHROUGH; - case 6: - XXH_PROCESS4; - XXH_PROCESS1; - XXH_PROCESS1; - return XXH32_avalanche(h32); + } - case 15: - XXH_PROCESS4; - XXH_FALLTHROUGH; - case 11: - XXH_PROCESS4; - XXH_FALLTHROUGH; - case 7: - XXH_PROCESS4; - XXH_FALLTHROUGH; - case 3: - XXH_PROCESS1; - XXH_FALLTHROUGH; - case 2: - XXH_PROCESS1; - XXH_FALLTHROUGH; - case 1: - XXH_PROCESS1; - XXH_FALLTHROUGH; - case 0: - return XXH32_avalanche(h32); + XXH_ASSERT(0); + return h32; /* reaching this point is deemed impossible */ } - XXH_ASSERT(0); - return h32; /* reaching this point is deemed impossible */ - - } - } #ifdef XXH_OLD_NAMES @@ -3385,6 +3389,7 @@ enum XXH_VECTOR_TYPE /* fake enum */ { (outHi) = vget_high_u32(vreinterpretq_u32_u64(in)); \ \ } while (0) + #else #define XXH_SPLIT_IN_PLACE(in, outLo, outHi) \ do { \ @@ -3393,6 +3398,7 @@ enum XXH_VECTOR_TYPE /* fake enum */ { (outHi) = vshrn_n_u64((in), 32); \ \ } while (0) + #endif #endif /* XXH_VECTOR == XXH_NEON */ diff --git a/instrumentation/split-compares-pass.so.cc b/instrumentation/split-compares-pass.so.cc index c06118c0..451258d9 100644 --- a/instrumentation/split-compares-pass.so.cc +++ b/instrumentation/split-compares-pass.so.cc @@ -882,7 +882,7 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) { // BUG FIXME TODO: u64 does not work for > 64 bit ... e.g. 80 and 128 bit if (sizeInBits > 64) { continue; } - IntegerType *intType = IntegerType::get(C, op_size); + IntegerType * intType = IntegerType::get(C, op_size); const unsigned int precision = sizeInBits == 32 ? 24 : sizeInBits == 64 ? 53 : sizeInBits == 128 ? 113 @@ -916,13 +916,14 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) { /* create the integers from floats directly */ Instruction *bpre_op0, *bpre_op1; bpre_op0 = CastInst::Create(Instruction::BitCast, op0, - IntegerType::get(C, op_size)); - bb->getInstList().insert(BasicBlock::iterator(bb->getTerminator()), bpre_op0); + IntegerType::get(C, op_size)); + bb->getInstList().insert(BasicBlock::iterator(bb->getTerminator()), + bpre_op0); bpre_op1 = CastInst::Create(Instruction::BitCast, op1, - IntegerType::get(C, op_size)); - bb->getInstList().insert(BasicBlock::iterator(bb->getTerminator()), bpre_op1); - + IntegerType::get(C, op_size)); + bb->getInstList().insert(BasicBlock::iterator(bb->getTerminator()), + bpre_op1); /* Check if any operand is NaN. * If so, all comparisons except unequal (which yields true) yield false */ @@ -940,41 +941,41 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) { /* Check op0 for NaN */ /* Shift left 1 Bit, ignore sign bit */ Instruction *nan_op0, *nan_op1; - nan_op0 = BinaryOperator::Create( - Instruction::Shl, bpre_op0, - ConstantInt::get(bpre_op0->getType(), 1)); - bb->getInstList().insert(BasicBlock::iterator(bb->getTerminator()), nan_op0); + nan_op0 = BinaryOperator::Create(Instruction::Shl, bpre_op0, + ConstantInt::get(bpre_op0->getType(), 1)); + bb->getInstList().insert(BasicBlock::iterator(bb->getTerminator()), + nan_op0); /* compare to NaN interval */ Instruction *is_op0_nan = - CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_UGT, nan_op0, ConstantInt::get(intType, NaN_lowend) ); + CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_UGT, nan_op0, + ConstantInt::get(intType, NaN_lowend)); bb->getInstList().insert(BasicBlock::iterator(bb->getTerminator()), is_op0_nan); /* Check op1 for NaN */ /* Shift right 1 Bit, ignore sign bit */ - nan_op1 = BinaryOperator::Create( - Instruction::Shl, bpre_op1, - ConstantInt::get(bpre_op1->getType(), 1)); - bb->getInstList().insert(BasicBlock::iterator(bb->getTerminator()), nan_op1); + nan_op1 = BinaryOperator::Create(Instruction::Shl, bpre_op1, + ConstantInt::get(bpre_op1->getType(), 1)); + bb->getInstList().insert(BasicBlock::iterator(bb->getTerminator()), + nan_op1); /* compare to NaN interval */ Instruction *is_op1_nan = - CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_UGT, nan_op1, ConstantInt::get(intType, NaN_lowend) ); + CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_UGT, nan_op1, + ConstantInt::get(intType, NaN_lowend)); bb->getInstList().insert(BasicBlock::iterator(bb->getTerminator()), is_op1_nan); /* combine checks */ - Instruction *is_nan = BinaryOperator::Create( - Instruction::Or, is_op0_nan, is_op1_nan); - bb->getInstList().insert(BasicBlock::iterator(bb->getTerminator()), - is_nan); + Instruction *is_nan = + BinaryOperator::Create(Instruction::Or, is_op0_nan, is_op1_nan); + bb->getInstList().insert(BasicBlock::iterator(bb->getTerminator()), is_nan); /* the result of the comparison, when at least one op is NaN is true only for the "NOT EQUAL" predicates. */ - bool NaNcmp_result = - FcmpInst->getPredicate() == CmpInst::FCMP_ONE || - FcmpInst->getPredicate() == CmpInst::FCMP_UNE; + bool NaNcmp_result = FcmpInst->getPredicate() == CmpInst::FCMP_ONE || + FcmpInst->getPredicate() == CmpInst::FCMP_UNE; BasicBlock *nonan_bb = BasicBlock::Create(C, "noNaN", end_bb->getParent(), end_bb); @@ -989,24 +990,30 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) { /*** now working in nonan_bb ***/ /* Treat -0.0 as equal to +0.0, that is for -0.0 make it +0.0 */ - Instruction *b_op0, *b_op1; - Instruction *isMzero_op0, *isMzero_op1; + Instruction * b_op0, *b_op1; + Instruction * isMzero_op0, *isMzero_op1; const unsigned long long MinusZero = 1UL << (sizeInBits - 1U); const unsigned long long PlusZero = 0; - isMzero_op0 = - CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ, bpre_op0, ConstantInt::get(intType, MinusZero)); - nonan_bb->getInstList().insert(BasicBlock::iterator(nonan_bb->getTerminator()), isMzero_op0); + isMzero_op0 = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ, bpre_op0, + ConstantInt::get(intType, MinusZero)); + nonan_bb->getInstList().insert( + BasicBlock::iterator(nonan_bb->getTerminator()), isMzero_op0); - isMzero_op1 = - CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ, bpre_op1, ConstantInt::get(intType, MinusZero)); - nonan_bb->getInstList().insert(BasicBlock::iterator(nonan_bb->getTerminator()), isMzero_op1); + isMzero_op1 = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ, bpre_op1, + ConstantInt::get(intType, MinusZero)); + nonan_bb->getInstList().insert( + BasicBlock::iterator(nonan_bb->getTerminator()), isMzero_op1); - b_op0 = SelectInst::Create(isMzero_op0, ConstantInt::get(intType, PlusZero), bpre_op0); - nonan_bb->getInstList().insert(BasicBlock::iterator(nonan_bb->getTerminator()), b_op0); + b_op0 = SelectInst::Create(isMzero_op0, ConstantInt::get(intType, PlusZero), + bpre_op0); + nonan_bb->getInstList().insert( + BasicBlock::iterator(nonan_bb->getTerminator()), b_op0); - b_op1 = SelectInst::Create(isMzero_op1, ConstantInt::get(intType, PlusZero), bpre_op1); - nonan_bb->getInstList().insert(BasicBlock::iterator(nonan_bb->getTerminator()), b_op1); + b_op1 = SelectInst::Create(isMzero_op1, ConstantInt::get(intType, PlusZero), + bpre_op1); + nonan_bb->getInstList().insert( + BasicBlock::iterator(nonan_bb->getTerminator()), b_op1); /* isolate signs of value of floating point type */ @@ -1017,22 +1024,26 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) { s_s0 = BinaryOperator::Create(Instruction::LShr, b_op0, ConstantInt::get(b_op0->getType(), op_size - 1)); - nonan_bb->getInstList().insert(BasicBlock::iterator(nonan_bb->getTerminator()), s_s0); + nonan_bb->getInstList().insert( + BasicBlock::iterator(nonan_bb->getTerminator()), s_s0); t_s0 = new TruncInst(s_s0, Int1Ty); - nonan_bb->getInstList().insert(BasicBlock::iterator(nonan_bb->getTerminator()), t_s0); + nonan_bb->getInstList().insert( + BasicBlock::iterator(nonan_bb->getTerminator()), t_s0); s_s1 = BinaryOperator::Create(Instruction::LShr, b_op1, ConstantInt::get(b_op1->getType(), op_size - 1)); - nonan_bb->getInstList().insert(BasicBlock::iterator(nonan_bb->getTerminator()), s_s1); + nonan_bb->getInstList().insert( + BasicBlock::iterator(nonan_bb->getTerminator()), s_s1); t_s1 = new TruncInst(s_s1, Int1Ty); - nonan_bb->getInstList().insert(BasicBlock::iterator(nonan_bb->getTerminator()), t_s1); + nonan_bb->getInstList().insert( + BasicBlock::iterator(nonan_bb->getTerminator()), t_s1); /* compare of the sign bits */ icmp_sign_bit = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ, t_s0, t_s1); - nonan_bb->getInstList().insert(BasicBlock::iterator(nonan_bb->getTerminator()), - icmp_sign_bit); + nonan_bb->getInstList().insert( + BasicBlock::iterator(nonan_bb->getTerminator()), icmp_sign_bit); /* create a new basic block which is executed if the signedness bits are * equal */ @@ -1440,8 +1451,8 @@ bool SplitComparesTransform::runOnModule(Module &M) { if (!be_quiet && !debug) { - errs() << "Split-floatingpoint-compare-pass: " << count - << " FP comparisons splitted\n"; + errs() << "Split-floatingpoint-compare-pass: " << count + << " FP comparisons splitted\n"; } diff --git a/test/test-cmplog.c b/test/test-cmplog.c index 262df6bd..1a314653 100644 --- a/test/test-cmplog.c +++ b/test/test-cmplog.c @@ -7,6 +7,7 @@ #include int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t i) { + if (i < 24) return 0; if (buf[0] != 'A') return 0; if (buf[1] != 'B') return 0; @@ -16,17 +17,25 @@ int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t i) { if (strncmp(buf + 12, "IJKL", 4) == 0 && strcmp(buf + 16, "DEADBEEF") == 0) abort(); return 0; + } #ifdef __AFL_COMPILER int main(int argc, char *argv[]) { - unsigned char buf[1024]; - ssize_t i; - while(__AFL_LOOP(1000)) { - i = read(0, (char*)buf, sizeof(buf) - 1); + + unsigned char buf[1024]; + ssize_t i; + while (__AFL_LOOP(1000)) { + + i = read(0, (char *)buf, sizeof(buf) - 1); if (i > 0) buf[i] = 0; LLVMFuzzerTestOneInput(buf, i); + } + return 0; + } + #endif + diff --git a/test/test-fp_Infcases.c b/test/test-fp_Infcases.c index 88a89ead..458202d6 100644 --- a/test/test-fp_Infcases.c +++ b/test/test-fp_Infcases.c @@ -6,23 +6,23 @@ #include #define _GNU_SOURCE -#include /* for NaNs and infinity values */ +#include /* for NaNs and infinity values */ int main() { volatile FLOAT_TYPE a, b; #ifdef INFINITY - FLOAT_TYPE inf = (FLOAT_TYPE) INFINITY; + FLOAT_TYPE inf = (FLOAT_TYPE)INFINITY; #else - FLOAT_TYPE inf = 1.0 / 0.0; /* produces infinity */ + FLOAT_TYPE inf = 1.0 / 0.0; /* produces infinity */ #endif FLOAT_TYPE negZero = 1.0 / -inf; FLOAT_TYPE posZero = 0.0; /* plus infinity */ - a = (1.0 / 0.0); /* positive infinity */ - b = (1.0 / 0.0); /* positive infinity */ + a = (1.0 / 0.0); /* positive infinity */ + b = (1.0 / 0.0); /* positive infinity */ assert(!(a < b)); assert((a <= b)); assert(!(a > b)); @@ -30,7 +30,7 @@ int main() { assert(!(a != b)); assert((a == b)); - b = -(1.0 / 0.0); /* negative infinity */ + b = -(1.0 / 0.0); /* negative infinity */ assert(!(a < b)); assert(!(a <= b)); assert((a > b)); @@ -38,7 +38,7 @@ int main() { assert((a != b)); assert(!(a == b)); - b = 1.0 / -(1.0 / 0.0); /* negative 0 */ + b = 1.0 / -(1.0 / 0.0); /* negative 0 */ assert(!(a < b)); assert(!(a <= b)); assert((a > b)); @@ -46,7 +46,7 @@ int main() { assert((a != b)); assert(!(a == b)); - b = 0.0; /* positive 0 */ + b = 0.0; /* positive 0 */ assert(!(a < b)); assert(!(a <= b)); assert((a > b)); @@ -71,8 +71,8 @@ int main() { assert(!(a == b)); /* negative infinity */ - a = -(1.0 / 0.0); - b = (1.0 / 0.0); /* positive infinity */ + a = -(1.0 / 0.0); + b = (1.0 / 0.0); /* positive infinity */ assert((a < b)); assert((a <= b)); assert(!(a > b)); @@ -80,7 +80,7 @@ int main() { assert((a != b)); assert(!(a == b)); - b = -(1.0 / 0.0); /* negative infinity */ + b = -(1.0 / 0.0); /* negative infinity */ assert(!(a < b)); assert((a <= b)); assert(!(a > b)); @@ -88,7 +88,7 @@ int main() { assert(!(a != b)); assert((a == b)); - b = 1.0 / -(1.0 / 0.0); /* negative 0 */ + b = 1.0 / -(1.0 / 0.0); /* negative 0 */ assert((a < b)); assert((a <= b)); assert(!(a > b)); @@ -96,7 +96,7 @@ int main() { assert((a != b)); assert(!(a == b)); - b = 0.0; /* positive 0 */ + b = 0.0; /* positive 0 */ assert((a < b)); assert((a <= b)); assert(!(a > b)); diff --git a/test/test-fp_NaNcases.c b/test/test-fp_NaNcases.c index 78d32711..94a0ff71 100644 --- a/test/test-fp_NaNcases.c +++ b/test/test-fp_NaNcases.c @@ -6,7 +6,7 @@ #include #define _GNU_SOURCE -#include /* for NaNs and infinity values */ +#include /* for NaNs and infinity values */ int main() { @@ -14,14 +14,14 @@ int main() { /* NaN */ #ifdef NAN - a = (FLOAT_TYPE) NAN; /* produces NaN */ + a = (FLOAT_TYPE)NAN; /* produces NaN */ #else - a = 0.0 / 0.0; /* produces NaN */ + a = 0.0 / 0.0; /* produces NaN */ #endif #ifdef INFINITY - FLOAT_TYPE inf = (FLOAT_TYPE) INFINITY; + FLOAT_TYPE inf = (FLOAT_TYPE)INFINITY; #else - FLOAT_TYPE inf = 1.0 / 0.0; /* produces infinity */ + FLOAT_TYPE inf = 1.0 / 0.0; /* produces infinity */ #endif FLOAT_TYPE negZero = 1.0 / -inf; FLOAT_TYPE posZero = 0.0; @@ -42,7 +42,7 @@ int main() { assert((a != b)); assert(!(a == b)); - b = 1.0 / -(1.0 / 0.0); /* negative 0 */ + b = 1.0 / -(1.0 / 0.0); /* negative 0 */ assert(!(a < b)); assert(!(a <= b)); assert(!(a > b)); @@ -66,7 +66,7 @@ int main() { assert((a != b)); assert(!(a == b)); - b = (1.0 / 0.0); /* positive infinity */ + b = (1.0 / 0.0); /* positive infinity */ assert(!(a < b)); assert(!(a <= b)); assert(!(a > b)); @@ -74,7 +74,7 @@ int main() { assert((a != b)); assert(!(a == b)); - b = -(1.0 / 0.0); /* negative infinity */ + b = -(1.0 / 0.0); /* negative infinity */ assert(!(a < b)); assert(!(a <= b)); assert(!(a > b)); diff --git a/test/test-fp_minusZerocases.c b/test/test-fp_minusZerocases.c index 00beef2e..f821f2ab 100644 --- a/test/test-fp_minusZerocases.c +++ b/test/test-fp_minusZerocases.c @@ -6,15 +6,15 @@ #include #define _GNU_SOURCE -#include /* for NaNs and infinity values */ +#include /* for NaNs and infinity values */ int main() { volatile FLOAT_TYPE a, b; /* negative zero */ - a = 1.0 / -(1.0 / 0.0); /* negative 0 */ - b = 0.0; /* positive 0 */ + a = 1.0 / -(1.0 / 0.0); /* negative 0 */ + b = 0.0; /* positive 0 */ assert(!(a < b)); assert((a <= b)); assert(!(a > b)); @@ -22,8 +22,8 @@ int main() { assert(!(a != b)); assert((a == b)); - a = 1.0 / -(1.0 / 0.0); /* negative 0 */ - b = 1.0 / -(1.0 / 0.0); /* negative 0 */ + a = 1.0 / -(1.0 / 0.0); /* negative 0 */ + b = 1.0 / -(1.0 / 0.0); /* negative 0 */ assert(!(a < b)); assert((a <= b)); assert(!(a > b)); diff --git a/utils/libtokencap/libtokencap.so.c b/utils/libtokencap/libtokencap.so.c index 2b1e3903..0db044a1 100644 --- a/utils/libtokencap/libtokencap.so.c +++ b/utils/libtokencap/libtokencap.so.c @@ -171,7 +171,7 @@ static void __tokencap_load_mappings(void) { int mib[] = {CTL_VM, VM_PROC, VM_PROC_MAP, __tokencap_pid, sizeof(struct kinfo_vmentry)}; #endif - char *buf, *low, *high; + char * buf, *low, *high; size_t miblen = sizeof(mib) / sizeof(mib[0]); size_t len; @@ -345,11 +345,7 @@ static void __tokencap_dump(const u8 *ptr, size_t len, u8 is_text) { wrt_ok &= (pos == write(__tokencap_out_file, buf, pos)); wrt_ok &= (2 == write(__tokencap_out_file, "\"\n", 2)); - if (!wrt_ok) { - - DEBUGF("%s", "writing to the token file failed\n"); - - } + if (!wrt_ok) { DEBUGF("%s", "writing to the token file failed\n"); } } -- cgit 1.4.1