[Mlir-commits] [mlir] [mlir][transforms] Skip `RemoveDeadValues` for function declaration (PR #108221)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Sep 11 06:32:51 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-core
Author: Longsheng Mou (CoTinker)
<details>
<summary>Changes</summary>
This patch skips `RemoveDeadValues` if funcOp is declaration, which fixes a crash.
Fixes #<!-- -->107546.
---
Full diff: https://github.com/llvm/llvm-project/pull/108221.diff
2 Files Affected:
- (modified) mlir/lib/Transforms/RemoveDeadValues.cpp (+2-2)
- (modified) mlir/test/Transforms/remove-dead-values.mlir (+5)
``````````diff
diff --git a/mlir/lib/Transforms/RemoveDeadValues.cpp b/mlir/lib/Transforms/RemoveDeadValues.cpp
index 055256903a1522..1cc0096805616c 100644
--- a/mlir/lib/Transforms/RemoveDeadValues.cpp
+++ b/mlir/lib/Transforms/RemoveDeadValues.cpp
@@ -191,10 +191,10 @@ static void cleanSimpleOp(Operation *op, RunLivenessAnalysis &la) {
/// non-live across all callers),
/// (5) Dropping the uses of these return values from its callers, AND
/// (6) Erasing these return values
-/// iff it is not public.
+/// iff it is not public or declaration.
static void cleanFuncOp(FunctionOpInterface funcOp, Operation *module,
RunLivenessAnalysis &la) {
- if (funcOp.isPublic())
+ if (funcOp.isPublic() || funcOp.isDeclaration())
return;
// Get the list of unnecessary (non-live) arguments in `nonLiveArgs`.
diff --git a/mlir/test/Transforms/remove-dead-values.mlir b/mlir/test/Transforms/remove-dead-values.mlir
index 69426fdb620832..41027a6a6632eb 100644
--- a/mlir/test/Transforms/remove-dead-values.mlir
+++ b/mlir/test/Transforms/remove-dead-values.mlir
@@ -357,3 +357,8 @@ func.func @kernel(%arg0: memref<18xf32>) {
// CHECK: gpu.launch blocks
// CHECK: memref.store
// CHECK-NEXT: gpu.terminator
+
+// -----
+
+// CHECK: func.func private @no_block_func_declaration() -> ()
+func.func private @no_block_func_declaration() -> ()
``````````
</details>
https://github.com/llvm/llvm-project/pull/108221
More information about the Mlir-commits
mailing list