[llvm] [FuzzMutate] Prevent the mutator from generating illegal memory operations (PR #144885)

Peter Rong via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 30 09:55:51 PDT 2025


================
@@ -89,23 +89,30 @@ void IterateOnSource(StringRef Source, IRMutator &Mutator) {
   }
 }
 
-static void mutateAndVerifyModule(StringRef Source,
-                                  std::unique_ptr<IRMutator> &Mutator,
-                                  int repeat = 100) {
+static void
+mutateAndVerifyModule(StringRef Source, std::unique_ptr<IRMutator> &Mutator,
+                      int repeat = 100,
+                      const std::function<void(Module &)> *Check = nullptr) {
----------------
DataCorrupted wrote:

1. The name `Check` is too vague, it could be checking anything, it could be doing anything. Use a more explicit name pls, e.g. `ExtraModuleVerifiers`
2. I'd prefer `const SmallVector<const std::function<void(Module &)>& ExtraModuleVerifiers = {}`, benefits here: a) in case we need more customized, target specific verifiers, we can put them together in this vector, b) instead of pointer check below you can do (unconditionally):

```
for (auto& ModuleVerifier: ExtraModuleVerifiers) {
    ModuleVerifier(M);
}
``` 

and c) the intention is more clear here.

https://github.com/llvm/llvm-project/pull/144885


More information about the llvm-commits mailing list