[llvm] [Fuzzer] llvm-isel-fuzzer: Add support for additional mutation strategies (PR #223327)
Afonso Bordado via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 14 01:28:30 PDT 2026
https://github.com/afonso360 created https://github.com/llvm/llvm-project/pull/223327
👋 Hey,
I've recently been running the ISel fuzzer and it was not generating what I expected in terms of modules.
I noticed we are missing some already preexisting strategies to generate more interesting inputs. These are:
- InstModificationIRStrategy
- InsertCFGStrategy
- InsertPHIStrategy
These allow us to modify flags in IR instructions, and create basic blocks and PHI's. Which allow for slightly more complex instruction selection.
I've been running this for about a day or so. It's been mostly stable under x86 with just one new unknown crash found (https://github.com/llvm/llvm-project/issues/223282)
For review I'm not entirely sure who I should ping: @bogner (Original Author) And maybe some recent reviewers in these modules? @DataCorrupted @chfast @mgcarrasco
>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 e28dd636cb7e0..5fbebb3b28d7a 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 5fbebb3b28d7a..384057b924a44 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