[llvm] a3aac56 - [IRMutator] Handle module with only declarations

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 11 05:30:59 PST 2022


Author: Nikita Popov
Date: 2022-03-11T14:20:39+01:00
New Revision: a3aac5693dab01242238b4568f46b0bd24927ac8

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

LOG: [IRMutator] Handle module with only declarations

There was a mismatch here, with one check checking whether there
are any functions, and the other collecting only non-declaration
functions.

Added: 
    

Modified: 
    llvm/lib/FuzzMutate/IRMutator.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/FuzzMutate/IRMutator.cpp b/llvm/lib/FuzzMutate/IRMutator.cpp
index 0cd0f538fdbcb..8078b36115f97 100644
--- a/llvm/lib/FuzzMutate/IRMutator.cpp
+++ b/llvm/lib/FuzzMutate/IRMutator.cpp
@@ -33,14 +33,15 @@ static void createEmptyFunction(Module &M) {
 }
 
 void IRMutationStrategy::mutate(Module &M, RandomIRBuilder &IB) {
-  if (M.empty())
-    createEmptyFunction(M);
-
   auto RS = makeSampler<Function *>(IB.Rand);
   for (Function &F : M)
     if (!F.isDeclaration())
       RS.sample(&F, /*Weight=*/1);
-  mutate(*RS.getSelection(), IB);
+
+  if (RS.isEmpty())
+    createEmptyFunction(M);
+  else
+    mutate(*RS.getSelection(), IB);
 }
 
 void IRMutationStrategy::mutate(Function &F, RandomIRBuilder &IB) {


        


More information about the llvm-commits mailing list