[Mlir-commits] [mlir] [mlir][transforms] Use `isExternal` instead of `isDeclaration` for `FunctionOpInterface` (PR #116573)
Longsheng Mou
llvmlistbot at llvm.org
Sun Nov 17 19:09:36 PST 2024
https://github.com/CoTinker created https://github.com/llvm/llvm-project/pull/116573
This PR fixes a bug in `RemoveDeadValues` where the `FunctionOpInterface` does not have the `isDeclaration` method. As a result, we should use the `isExternal` method instead. Fixes #116347.
>From 76e55dfe33112102d3b95a8177301ad16b68c135 Mon Sep 17 00:00:00 2001
From: Longsheng Mou <longshengmou at gmail.com>
Date: Mon, 18 Nov 2024 11:04:12 +0800
Subject: [PATCH 1/2] [mlir][transforms] Use `isExternal` instead of
`isDeclaration` for `FunctionOpInterface`
This PR fixes a bug in `RemoveDeadValues` where the `FunctionOpInterface` does not have the `isDeclaration` method. As a result, we should use the `isExternal` method instead.
---
mlir/lib/Transforms/RemoveDeadValues.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mlir/lib/Transforms/RemoveDeadValues.cpp b/mlir/lib/Transforms/RemoveDeadValues.cpp
index 7e45f18b660ba7..9f942485711297 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 or declaration.
+/// iff it is not public or external.
static void cleanFuncOp(FunctionOpInterface funcOp, Operation *module,
RunLivenessAnalysis &la) {
- if (funcOp.isPublic() || funcOp.isDeclaration())
+ if (funcOp.isPublic() || funcOp.isExternal())
return;
// Get the list of unnecessary (non-live) arguments in `nonLiveArgs`.
>From 68d4ef41222d21206bf74758c55b91a1f7e6c7d6 Mon Sep 17 00:00:00 2001
From: Longsheng Mou <longshengmou at gmail.com>
Date: Mon, 18 Nov 2024 11:07:18 +0800
Subject: [PATCH 2/2] Add tests
---
mlir/test/Transforms/remove-dead-values.mlir | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mlir/test/Transforms/remove-dead-values.mlir b/mlir/test/Transforms/remove-dead-values.mlir
index 9f2be3331b6b4b..edb100acf3849b 100644
--- a/mlir/test/Transforms/remove-dead-values.mlir
+++ b/mlir/test/Transforms/remove-dead-values.mlir
@@ -374,3 +374,8 @@ func.func @kernel(%arg0: memref<18xf32>) {
// CHECK: func.func private @no_block_func_declaration()
func.func private @no_block_func_declaration() -> ()
+
+// -----
+
+// CHECK: llvm.func @no_block_external_func()
+llvm.func @no_block_external_func() attributes {sym_visibility = "private"}
More information about the Mlir-commits
mailing list