LTO: autodict default, instrim disabled
MODIFY
docs/Changelog.md
docs/Changelog.md
@@ -12,6 +12,11 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
### Version ++2.66d (devel)
- afl-fuzz:
- eliminated CPU affinity race condition for -S/-M runs
+ - llvm_mode:
+ - fix for laf-intel float splitting
+ - LTO: autodictionary mode is a default
+ - LTO: instrim instrumentation disabled, only classic support used
+ as it is always better
- small fixes to afl-plot, afl-whatsup and man page creation

MODIFY
llvm_mode/afl-clang-fast.c
llvm_mode/afl-clang-fast.c
@@ -311,10 +311,13 @@ static void edit_params(u32 argc, char **argv, char **envp) {
cc_params[cc_par_cnt++] = alloc_printf("-fuse-ld=%s", AFL_REAL_LD);
cc_params[cc_par_cnt++] = "-Wl,--allow-multiple-definition";
+ /*
+ The current LTO instrim mode is not good, so we disable it
if (instrument_mode == INSTRUMENT_CFG)
cc_params[cc_par_cnt++] =
- alloc_printf("-Wl,-mllvm=-load=%s/afl-llvm-lto-instrim.so", obj_path);
- else
+ alloc_printf("-Wl,-mllvm=-load=%s/afl-llvm-lto-instrim.so",
+ obj_path); else
+ */
cc_params[cc_par_cnt++] = alloc_printf(
"-Wl,-mllvm=-load=%s/afl-llvm-lto-instrumentation.so", obj_path);
cc_params[cc_par_cnt++] = lto_flag;
@@ -379,8 +382,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
if (!strcmp(cur, "-Wl,-z,defs") || !strcmp(cur, "-Wl,--no-undefined"))
continue;
- if (lto_mode && !strncmp(cur, "-fuse-ld=", 9))
- continue;
+ if (lto_mode && !strncmp(cur, "-fuse-ld=", 9)) continue;
cc_params[cc_par_cnt++] = cur;

MODIFY
llvm_mode/afl-llvm-lto-instrim.so.cc
llvm_mode/afl-llvm-lto-instrim.so.cc
@@ -73,7 +73,7 @@ struct InsTrimLTO : public ModulePass {
protected:
uint32_t function_minimum_size = 1;
char * skip_nozero = NULL;
- int afl_global_id = 1, debug = 0, autodictionary = 0;
+ int afl_global_id = 1, debug = 0, autodictionary = 1;
uint32_t be_quiet = 0, inst_blocks = 0, inst_funcs = 0;
uint64_t map_addr = 0x10000;
@@ -127,10 +127,6 @@ struct InsTrimLTO : public ModulePass {
/* Process environment variables */
- if (getenv("AFL_LLVM_AUTODICTIONARY") ||
- getenv("AFL_LLVM_LTO_AUTODICTIONARY"))
- autodictionary = 1;
-
if (getenv("AFL_LLVM_MAP_DYNAMIC")) map_addr = 0;
if ((ptr = getenv("AFL_LLVM_MAP_ADDR"))) {

MODIFY
llvm_mode/afl-llvm-lto-instrumentation.so.cc
llvm_mode/afl-llvm-lto-instrumentation.so.cc
@@ -86,7 +86,7 @@ class AFLLTOPass : public ModulePass {
bool runOnModule(Module &M) override;
protected:
- int afl_global_id = 1, debug = 0, autodictionary = 0;
+ int afl_global_id = 1, debug = 0, autodictionary = 1;
uint32_t function_minimum_size = 1;
uint32_t be_quiet = 0, inst_blocks = 0, inst_funcs = 0, total_instr = 0;
uint64_t map_addr = 0x10000;
@@ -120,10 +120,6 @@ bool AFLLTOPass::runOnModule(Module &M) {
be_quiet = 1;
- if (getenv("AFL_LLVM_AUTODICTIONARY") ||
- getenv("AFL_LLVM_LTO_AUTODICTIONARY"))
- autodictionary = 1;
-
if (getenv("AFL_LLVM_MAP_DYNAMIC")) map_addr = 0;
if (getenv("AFL_LLVM_INSTRIM_SKIPSINGLEBLOCK") ||

MODIFY
llvm_mode/split-compares-pass.so.cc
llvm_mode/split-compares-pass.so.cc
@@ -93,6 +93,7 @@ char SplitComparesTransform::ID = 0;
/* This function splits FCMP instructions with xGE or xLE predicates into two
* FCMP instructions with predicate xGT or xLT and EQ */
bool SplitComparesTransform::simplifyFPCompares(Module &M) {
+
LLVMContext & C = M.getContext();
std::vector<Instruction *> fcomps;
IntegerType * Int1Ty = IntegerType::getInt1Ty(C);
@@ -755,20 +756,24 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) {
icmp_exponents_equal =
CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ, m_e0, m_e1);
signequal_bb->getInstList().insert(
- BasicBlock::iterator(signequal_bb->getTerminator()), icmp_exponents_equal);
+ BasicBlock::iterator(signequal_bb->getTerminator()),
+ icmp_exponents_equal);
// shortcut for unequal exponents
- signequal2_bb = signequal_bb->splitBasicBlock(BasicBlock::iterator(signequal_bb->getTerminator()));
+ signequal2_bb = signequal_bb->splitBasicBlock(
+ BasicBlock::iterator(signequal_bb->getTerminator()));
/* if the exponents are equal goto middle_bb else to signequal2_bb */
term = signequal_bb->getTerminator();
- BranchInst::Create(middle_bb, signequal2_bb, icmp_exponents_equal, signequal_bb);
+ BranchInst::Create(middle_bb, signequal2_bb, icmp_exponents_equal,
+ signequal_bb);
term->eraseFromParent();
icmp_exponent =
CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_UGT, m_e0, m_e1);
signequal2_bb->getInstList().insert(
- BasicBlock::iterator(signequal2_bb->getTerminator()), icmp_exponent);
+ BasicBlock::iterator(signequal2_bb->getTerminator()),
+ icmp_exponent);
icmp_exponent_result =
BinaryOperator::Create(Instruction::Xor, icmp_exponent, t_s0);
break;
@@ -777,20 +782,24 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) {
icmp_exponents_equal =
CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ, m_e0, m_e1);
signequal_bb->getInstList().insert(
- BasicBlock::iterator(signequal_bb->getTerminator()), icmp_exponents_equal);
+ BasicBlock::iterator(signequal_bb->getTerminator()),
+ icmp_exponents_equal);
// shortcut for unequal exponents
- signequal2_bb = signequal_bb->splitBasicBlock(BasicBlock::iterator(signequal_bb->getTerminator()));
+ signequal2_bb = signequal_bb->splitBasicBlock(
+ BasicBlock::iterator(signequal_bb->getTerminator()));
/* if the exponents are equal goto middle_bb else to signequal2_bb */
term = signequal_bb->getTerminator();
- BranchInst::Create(middle_bb, signequal2_bb, icmp_exponents_equal, signequal_bb);
+ BranchInst::Create(middle_bb, signequal2_bb, icmp_exponents_equal,
+ signequal_bb);
term->eraseFromParent();
icmp_exponent =
CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_ULT, m_e0, m_e1);
signequal2_bb->getInstList().insert(
- BasicBlock::iterator(signequal2_bb->getTerminator()), icmp_exponent);
+ BasicBlock::iterator(signequal2_bb->getTerminator()),
+ icmp_exponent);
icmp_exponent_result =
BinaryOperator::Create(Instruction::Xor, icmp_exponent, t_s0);
break;
@@ -808,14 +817,19 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) {
term = signequal2_bb->getTerminator();
switch (FcmpInst->getPredicate()) {
+
case CmpInst::FCMP_OEQ:
- /* if the exponents are satifying the compare do a fraction cmp in middle_bb */
- BranchInst::Create(middle_bb, end_bb, icmp_exponent_result, signequal2_bb);
+ /* if the exponents are satifying the compare do a fraction cmp in
+ * middle_bb */
+ BranchInst::Create(middle_bb, end_bb, icmp_exponent_result,
+ signequal2_bb);
break;
case CmpInst::FCMP_ONE:
case CmpInst::FCMP_UNE:
- /* if the exponents are satifying the compare do a fraction cmp in middle_bb */
- BranchInst::Create(end_bb, middle_bb, icmp_exponent_result, signequal2_bb);
+ /* if the exponents are satifying the compare do a fraction cmp in
+ * middle_bb */
+ BranchInst::Create(end_bb, middle_bb, icmp_exponent_result,
+ signequal2_bb);
break;
case CmpInst::FCMP_OGT:
case CmpInst::FCMP_UGT:
@@ -897,7 +911,8 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) {
icmp_fraction_result =
CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_EQ, t_f0, t_f1);
middle2_bb->getInstList().insert(
- BasicBlock::iterator(middle2_bb->getTerminator()), icmp_fraction_result);
+ BasicBlock::iterator(middle2_bb->getTerminator()),
+ icmp_fraction_result);
break;
case CmpInst::FCMP_UNE:
@@ -905,30 +920,44 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) {
icmp_fraction_result =
CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_NE, t_f0, t_f1);
middle2_bb->getInstList().insert(
- BasicBlock::iterator(middle2_bb->getTerminator()), icmp_fraction_result);
+ BasicBlock::iterator(middle2_bb->getTerminator()),
+ icmp_fraction_result);
break;
case CmpInst::FCMP_OGT:
case CmpInst::FCMP_UGT:
case CmpInst::FCMP_OLT:
- case CmpInst::FCMP_ULT:
- {
- middle2_bb = middle_bb->splitBasicBlock(BasicBlock::iterator(middle_bb->getTerminator()));
+ case CmpInst::FCMP_ULT: {
- BasicBlock * negative_bb =
- BasicBlock::Create(C, "negative_value", middle2_bb->getParent(), middle2_bb);
- BasicBlock * positive_bb =
- BasicBlock::Create(C, "positive_value", negative_bb->getParent(), negative_bb);
+ middle2_bb = middle_bb->splitBasicBlock(
+ BasicBlock::iterator(middle_bb->getTerminator()));
- if (FcmpInst->getPredicate() == CmpInst::FCMP_OGT
- ||
+ BasicBlock *negative_bb = BasicBlock::Create(
+ C, "negative_value", middle2_bb->getParent(), middle2_bb);
+ BasicBlock *positive_bb = BasicBlock::Create(
+ C, "positive_value", negative_bb->getParent(), negative_bb);
+
+ if (FcmpInst->getPredicate() == CmpInst::FCMP_OGT ||
FcmpInst->getPredicate() == CmpInst::FCMP_UGT) {
- negative_bb->getInstList().push_back(icmp_fraction_result = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_ULT, t_f0, t_f1));
- positive_bb->getInstList().push_back(icmp_fraction_result2 = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_UGT, t_f0, t_f1));
+
+ negative_bb->getInstList().push_back(
+ icmp_fraction_result = CmpInst::Create(
+ Instruction::ICmp, CmpInst::ICMP_ULT, t_f0, t_f1));
+ positive_bb->getInstList().push_back(
+ icmp_fraction_result2 = CmpInst::Create(
+ Instruction::ICmp, CmpInst::ICMP_UGT, t_f0, t_f1));
+
} else {
- negative_bb->getInstList().push_back(icmp_fraction_result = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_UGT, t_f0, t_f1));
- positive_bb->getInstList().push_back(icmp_fraction_result2 = CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_ULT, t_f0, t_f1));
+
+ negative_bb->getInstList().push_back(
+ icmp_fraction_result = CmpInst::Create(
+ Instruction::ICmp, CmpInst::ICMP_UGT, t_f0, t_f1));
+ positive_bb->getInstList().push_back(
+ icmp_fraction_result2 = CmpInst::Create(
+ Instruction::ICmp, CmpInst::ICMP_ULT, t_f0, t_f1));
+
}
+
BranchInst::Create(middle2_bb, negative_bb);
BranchInst::Create(middle2_bb, positive_bb);
@@ -942,8 +971,8 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) {
middle2_bb->getInstList().insert(
BasicBlock::iterator(middle2_bb->getTerminator()), PN2);
- }
- break;
+ } break;
+
default:
continue;

LTO: autodict default, instrim disabled