[Mlir-commits] [mlir] [MLIR] RemoveDeadValues: Allowing IRs with global constants to get dead values removed (PR #116519)
Renat Idrisov
llvmlistbot at llvm.org
Sat Nov 16 17:47:44 PST 2024
https://github.com/parsifal-47 created https://github.com/llvm/llvm-project/pull/116519
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
>From 75a6efbed619e738196cebfd244cc0702f533b43 Mon Sep 17 00:00:00 2001
From: Renat Idrisov <parsifal-47 at users.noreply.github.com>
Date: Sat, 16 Nov 2024 21:16:25 +0000
Subject: [PATCH] Allowing IRs with global constants to get dead values removed
---
mlir/lib/Transforms/RemoveDeadValues.cpp | 1 -
mlir/test/Transforms/remove-dead-values.mlir | 6 +++---
2 files changed, 3 insertions(+), 4 deletions(-)
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
}
}
More information about the Mlir-commits
mailing list