[llvm] [Fuzzer] llvm-isel-fuzzer: Add support for additional mutation strategies (PR #223327)

Afonso Bordado via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 19 01:40:30 PDT 2026


https://github.com/afonso360 updated https://github.com/llvm/llvm-project/pull/223327

>From 3cdbb9d72b934db52df794562c7263473e672427 Mon Sep 17 00:00:00 2001
From: Afonso Bordado <afonsobordado at az8.co>
Date: Fri, 11 Sep 2026 16:35:39 +0100
Subject: [PATCH 1/2] llvm-isel-fuzzer: Add IR flags to fuzzed modules

This Commit adds support for the fuzzer to pick the `InstModificationIRStrategy`
that allows it to add additional flags to instructions, such as `nsw`/`nuw`/etc...
---
 llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp b/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
index e28dd636cb7e0c..5fbebb3b28d7a1 100644
--- a/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
+++ b/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
@@ -58,6 +58,7 @@ std::unique_ptr<IRMutator> createISelMutator() {
   std::vector<std::unique_ptr<IRMutationStrategy>> Strategies;
   Strategies.emplace_back(
       new InjectorIRStrategy(InjectorIRStrategy::getDefaultOps()));
+  Strategies.emplace_back(new InstModificationIRStrategy());
   Strategies.emplace_back(new InstDeleterIRStrategy());
 
   return std::make_unique<IRMutator>(std::move(Types), std::move(Strategies));

>From 1617250c2210e81108db318e341f4eb41dff434d Mon Sep 17 00:00:00 2001
From: Afonso Bordado <afonsobordado at az8.co>
Date: Sat, 12 Sep 2026 11:18:04 +0100
Subject: [PATCH 2/2] llvm-isel-fuzzer: Add Blocks and PHI's to fuzzed modules

This PR adds two new strategies to the llvm isel fuzzer:

- InsertCFGStrategy
- InsertPHIStrategy

Together these allow the fuzzer to both create new basic blocks, and
insert PHI's at the top of basic blocks to achieve more coverage.
---
 llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp b/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
index 5fbebb3b28d7a1..384057b924a442 100644
--- a/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
+++ b/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
@@ -59,6 +59,8 @@ std::unique_ptr<IRMutator> createISelMutator() {
   Strategies.emplace_back(
       new InjectorIRStrategy(InjectorIRStrategy::getDefaultOps()));
   Strategies.emplace_back(new InstModificationIRStrategy());
+  Strategies.emplace_back(new InsertCFGStrategy());
+  Strategies.emplace_back(new InsertPHIStrategy());
   Strategies.emplace_back(new InstDeleterIRStrategy());
 
   return std::make_unique<IRMutator>(std::move(Types), std::move(Strategies));



More information about the llvm-commits mailing list