Skip to content

Commit 16ae493

Browse files
[FuzzMutate] Only use undef when explictly asked to (#84959)
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 <[email protected]>
1 parent c1ac9a0 commit 16ae493

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

llvm/lib/FuzzMutate/OpDescriptor.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@
88

99
#include "llvm/FuzzMutate/OpDescriptor.h"
1010
#include "llvm/IR/Constants.h"
11+
#include "llvm/Support/CommandLine.h"
1112

1213
using namespace llvm;
1314
using namespace fuzzerop;
1415

16+
static cl::opt<bool> UseUndef("use-undef",
17+
cl::desc("Use undef when generating programs."),
18+
cl::init(false));
19+
1520
void fuzzerop::makeConstantsWithType(Type *T, std::vector<Constant *> &Cs) {
1621
if (auto *IntTy = dyn_cast<IntegerType>(T)) {
1722
uint64_t W = IntTy->getBitWidth();
@@ -42,7 +47,8 @@ void fuzzerop::makeConstantsWithType(Type *T, std::vector<Constant *> &Cs) {
4247
Cs.push_back(ConstantVector::getSplat(EC, Elt));
4348
}
4449
} else {
45-
Cs.push_back(UndefValue::get(T));
50+
if (UseUndef)
51+
Cs.push_back(UndefValue::get(T));
4652
Cs.push_back(PoisonValue::get(T));
4753
}
4854
}

0 commit comments

Comments
 (0)