[Mlir-commits] [mlir] 1208699 - [mlir][transforms] Skip `RemoveDeadValues` for function declaration (#108221)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Sep 14 06:24:55 PDT 2024
Author: Longsheng Mou
Date: 2024-09-14T21:24:51+08:00
New Revision: 12086996183c6c1f3e390848b67036a6c826b3fb
URL: https://github.com/llvm/llvm-project/commit/12086996183c6c1f3e390848b67036a6c826b3fb
DIFF: https://github.com/llvm/llvm-project/commit/12086996183c6c1f3e390848b67036a6c826b3fb.diff
LOG: [mlir][transforms] Skip `RemoveDeadValues` for function declaration (#108221)
This patch skips `RemoveDeadValues` if funcOp is declaration, which
fixes a crash.
Fixes #107546.
Added:
Modified:
mlir/lib/Transforms/RemoveDeadValues.cpp
mlir/test/Transforms/remove-dead-values.mlir
Removed:
################################################################################
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..a31cb97cb57125 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() -> ()
More information about the Mlir-commits
mailing list