Skip to content

Commit

Permalink
[FuzzMutate] Only use undef when explictly asked to (#84959)
Browse files Browse the repository at this point in the history
Per discussion in SecurityLab-UCD/IRFuzzer#49,
generating undef during fuzzing seems to be less fruitful. Let's
eliminate undef in favor of poison unless the user explicitly asked for
it.

Signed-off-by: Peter Rong <PeterRong96@gmail.com>
  • Loading branch information
DataCorrupted committed Mar 13, 2024
1 parent c1ac9a0 commit 16ae493
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion llvm/lib/FuzzMutate/OpDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@

#include "llvm/FuzzMutate/OpDescriptor.h"
#include "llvm/IR/Constants.h"
#include "llvm/Support/CommandLine.h"

using namespace llvm;
using namespace fuzzerop;

static cl::opt<bool> UseUndef("use-undef",
cl::desc("Use undef when generating programs."),
cl::init(false));

void fuzzerop::makeConstantsWithType(Type *T, std::vector<Constant *> &Cs) {
if (auto *IntTy = dyn_cast<IntegerType>(T)) {
uint64_t W = IntTy->getBitWidth();
Expand Down Expand Up @@ -42,7 +47,8 @@ void fuzzerop::makeConstantsWithType(Type *T, std::vector<Constant *> &Cs) {
Cs.push_back(ConstantVector::getSplat(EC, Elt));
}
} else {
Cs.push_back(UndefValue::get(T));
if (UseUndef)
Cs.push_back(UndefValue::get(T));
Cs.push_back(PoisonValue::get(T));
}
}
Expand Down

0 comments on commit 16ae493

Please sign in to comment.