[Mlir-commits] [mlir] [mlir] Fix `remove-dead-values` pass throws error when module has a name (PR #109990)

Longsheng Mou llvmlistbot at llvm.org
Mon Sep 30 01:58:57 PDT 2024


================
@@ -1,13 +1,25 @@
 // 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 (module @dont_touch_unacceptable_ir).
+// symbol op inside the module (const @__dont_touch_unacceptable_ir).
 //
+module {
 // expected-error @+1 {{cannot optimize an IR with non-function symbol ops, non-call symbol user ops or branch ops}}
-module @dont_touch_unacceptable_ir {
-  func.func @has_cleanable_simple_op(%arg0 : i32) {
-    %non_live = arith.addi %arg0, %arg0 : i32
-    return
+  memref.global "private" constant @__dont_touch_unacceptable_ir : memref<i32> = dense<0>
+  func.func @main(%arg0: i32) -> i32 {
+    return %arg0 : i32
+  }
+}
+
+// -----
+
+// Dead values are removed from the IR even if the module has a name
+//
+module @named_module_acceptable {
+  func.func @main(%arg0: tensor<10xf32>) -> tensor<10xf32> {
+    %0 = tensor.empty() : tensor<10xbf16>
+    // CHECK-NOT: %[[C:.*]] = tensor.empty[[C:.*]]
----------------
CoTinker wrote:

Maybe change it to `// CHECK-NOT: tensor.empty` is better.

https://github.com/llvm/llvm-project/pull/109990


More information about the Mlir-commits mailing list