[Mlir-commits] [mlir] [MLIR] RemoveDeadValues: Allowing IRs with global constants to get dead values removed (PR #116519)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Nov 16 17:48:40 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-core
Author: Renat Idrisov (parsifal-47)
<details>
<summary>Changes</summary>
This change is related to discussion:
https://discourse.llvm.org/t/question-on-criteria-for-acceptable-ir-in-removedeadvaluespass/83131
I do not know the original reason to disallow the optimization on modules with global private constant. Please let me know what am I missing, I will be happy to make it better. Thank you!
CC: @<!-- -->Wheest
---
Full diff: https://github.com/llvm/llvm-project/pull/116519.diff
2 Files Affected:
- (modified) mlir/lib/Transforms/RemoveDeadValues.cpp (-1)
- (modified) mlir/test/Transforms/remove-dead-values.mlir (+3-3)
``````````diff
diff --git a/mlir/lib/Transforms/RemoveDeadValues.cpp b/mlir/lib/Transforms/RemoveDeadValues.cpp
index 7e45f18b660ba7..edfb1969ab75c7 100644
--- a/mlir/lib/Transforms/RemoveDeadValues.cpp
+++ b/mlir/lib/Transforms/RemoveDeadValues.cpp
@@ -579,7 +579,6 @@ void RemoveDeadValues::runOnOperation() {
if (op == module)
return WalkResult::advance();
if (isa<BranchOpInterface>(op) ||
- (isa<SymbolOpInterface>(op) && !isa<FunctionOpInterface>(op)) ||
(isa<SymbolUserOpInterface>(op) && !isa<CallOpInterface>(op))) {
op->emitError() << "cannot optimize an IR with non-function symbol ops, "
"non-call symbol user ops or branch ops\n";
diff --git a/mlir/test/Transforms/remove-dead-values.mlir b/mlir/test/Transforms/remove-dead-values.mlir
index 9f2be3331b6b4b..b06b3320706cc8 100644
--- a/mlir/test/Transforms/remove-dead-values.mlir
+++ b/mlir/test/Transforms/remove-dead-values.mlir
@@ -1,12 +1,12 @@
// RUN: mlir-opt %s -remove-dead-values -split-input-file -verify-diagnostics | FileCheck %s
-// The IR remains untouched because of the presence of a non-function-like
-// symbol op inside the module (const @__dont_touch_unacceptable_ir).
+// The IR is updated regardless of memref.global private constant
//
module {
-// expected-error @+1 {{cannot optimize an IR with non-function symbol ops, non-call symbol user ops or branch ops}}
memref.global "private" constant @__dont_touch_unacceptable_ir : memref<i32> = dense<0>
func.func @main(%arg0: i32) -> i32 {
+ %0 = tensor.empty() : tensor<10xbf16>
+ // CHECK-NOT: tensor.empty
return %arg0 : i32
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/116519
More information about the Mlir-commits
mailing list