[llvm] 16ae493 - [FuzzMutate] Only use undef when explictly asked to (#84959)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 12 18:07:48 PDT 2024


Author: Peter Rong
Date: 2024-03-12T18:07:44-07:00
New Revision: 16ae493f56c1857ec0f6f2777e9b8a2e5151b4ef

URL: https://github.com/llvm/llvm-project/commit/16ae493f56c1857ec0f6f2777e9b8a2e5151b4ef
DIFF: https://github.com/llvm/llvm-project/commit/16ae493f56c1857ec0f6f2777e9b8a2e5151b4ef.diff

LOG: [FuzzMutate] Only use undef when explictly asked to (#84959)

Per discussion in https://github.com/SecurityLab-UCD/IRFuzzer/issues/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 at gmail.com>

Added: 
    

Modified: 
    llvm/lib/FuzzMutate/OpDescriptor.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/FuzzMutate/OpDescriptor.cpp b/llvm/lib/FuzzMutate/OpDescriptor.cpp
index 4baf45284de105..6ec70d917918f3 100644
--- a/llvm/lib/FuzzMutate/OpDescriptor.cpp
+++ b/llvm/lib/FuzzMutate/OpDescriptor.cpp
@@ -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();
@@ -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));
   }
 }


        


More information about the llvm-commits mailing list