[Mlir-commits] [mlir] [mlir][lR] Add Check For Functions with Zero Results in "test-func-erase-result" Pass (PR #127941)
Ayokunle Amodu
llvmlistbot at llvm.org
Wed Feb 19 18:18:41 PST 2025
https://github.com/ayokunle321 created https://github.com/llvm/llvm-project/pull/127941
Fixes #119353.
The pass tries to erase the result of a function with zero results which leads to an assertion error - so I added a check to ensure that a function is skipped if it has no results.
Not really sure how to write the test for this as I don't really understand how the tests in `test-func-erase-result.mlir` work. Also note that the functions that caused the crash (included in the issue mentioned above) are with declarations.
>From 70bc196571e107e1609a50b930325520f83c43c4 Mon Sep 17 00:00:00 2001
From: Ayokunle Amodu <121697771+ayokunle321 at users.noreply.github.com>
Date: Wed, 19 Feb 2025 18:53:22 -0700
Subject: [PATCH 1/2] added check for zero results
---
mlir/test/lib/IR/TestFunc.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mlir/test/lib/IR/TestFunc.cpp b/mlir/test/lib/IR/TestFunc.cpp
index 2ade47249863c..c832044c8dee7 100644
--- a/mlir/test/lib/IR/TestFunc.cpp
+++ b/mlir/test/lib/IR/TestFunc.cpp
@@ -9,6 +9,8 @@
#include "mlir/IR/BuiltinOps.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
#include "mlir/Pass/Pass.h"
+#include <iostream>
+#include <stdlib.h>
using namespace mlir;
@@ -118,6 +120,8 @@ struct TestFuncEraseResult
auto module = getOperation();
for (auto func : module.getOps<FunctionOpInterface>()) {
+ if (!func.getNumResults())
+ continue;
BitVector indicesToErase(func.getNumResults());
for (auto resultIndex : llvm::seq<int>(0, func.getNumResults()))
if (func.getResultAttr(resultIndex, "test.erase_this_result"))
>From 8c06a93251fbd142902bed85ff3975814d6ad057 Mon Sep 17 00:00:00 2001
From: Ayokunle Amodu <121697771+ayokunle321 at users.noreply.github.com>
Date: Wed, 19 Feb 2025 19:01:13 -0700
Subject: [PATCH 2/2] remove unneccessary headers
---
mlir/test/lib/IR/TestFunc.cpp | 2 --
1 file changed, 2 deletions(-)
diff --git a/mlir/test/lib/IR/TestFunc.cpp b/mlir/test/lib/IR/TestFunc.cpp
index c832044c8dee7..2a367e31ac3d4 100644
--- a/mlir/test/lib/IR/TestFunc.cpp
+++ b/mlir/test/lib/IR/TestFunc.cpp
@@ -9,8 +9,6 @@
#include "mlir/IR/BuiltinOps.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
#include "mlir/Pass/Pass.h"
-#include <iostream>
-#include <stdlib.h>
using namespace mlir;
More information about the Mlir-commits
mailing list