[llvm] [FuzzMutate] Prevent the mutator from generating invalid IR caused by non-callable CCs (PR #139080)

Manuel Carrasco via llvm-commits llvm-commits at lists.llvm.org
Thu May 8 06:16:55 PDT 2025


https://github.com/mgcarrasco created https://github.com/llvm/llvm-project/pull/139080

The current implementation can generate invalid IR due to illegal use of CCs. This matches the behaviour of the IRVerifier.

>From 5d86a7252982573a00cb7935da43ed7f16268745 Mon Sep 17 00:00:00 2001
From: Manuel Carrasco <Manuel.Carrasco at amd.com>
Date: Thu, 8 May 2025 06:11:24 -0700
Subject: [PATCH] [FuzzMutate] Prevent the mutator from generating invalid IR
 caused by non-callable CCs.

---
 llvm/lib/FuzzMutate/IRMutator.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/FuzzMutate/IRMutator.cpp b/llvm/lib/FuzzMutate/IRMutator.cpp
index 7e28f58046b1f..bd23f631a4689 100644
--- a/llvm/lib/FuzzMutate/IRMutator.cpp
+++ b/llvm/lib/FuzzMutate/IRMutator.cpp
@@ -374,7 +374,7 @@ void InsertFunctionStrategy::mutate(BasicBlock &BB, RandomIRBuilder &IB) {
     return T->isMetadataTy() || T->isTokenTy();
   };
   if (!F || IsUnsupportedTy(F->getReturnType()) ||
-      any_of(F->getFunctionType()->params(), IsUnsupportedTy)) {
+      any_of(F->getFunctionType()->params(), IsUnsupportedTy) || !isCallableCC(F->getCallingConv())) {
     F = IB.createFunctionDeclaration(*M);
   }
 



More information about the llvm-commits mailing list