[Mlir-commits] [mlir] [mlir] Walk nested non-symbol table ops in symbol dce (PR #143353)

Mehdi Amini llvmlistbot at llvm.org
Tue Jun 24 02:49:43 PDT 2025


================
@@ -98,3 +98,22 @@ module {
   // CHECK: "live.user"() {uses = [@unknown_symbol]} : () -> ()
   "live.user"() {uses = [@unknown_symbol]} : () -> ()
 }
+
+// -----
+
+// Check that we don't DCE nested symbols if they are used even if nested inside
+// an unnamed region.
+// CHECK-LABEL: module attributes {test.nested_unnamed_region}
+module attributes {test.nested_unnamed_region} {
+  "test.one_region_op"() ({
+    "test.symbol_scope"() ({
+      // CHECK: func @nfunction
+      func.func @nfunction() {
----------------
joker-eph wrote:

```suggestion
      func.func nested @nfunction() {
```

I think that is one thing you're trying to fix.

However a simpler test right now would be:

```


module {
  "test.one_region_op"() ({
    module {
        func.func nested @nested() {
            return
        }

        func.func @main() {
            return
        }
    }
    "test.finish"() : () -> ()
  }) : () -> ()
}
```

Where @main should not be removed but @nested should be. Can you also add this test? It can be a good "documentation" as well of the expected behavior.

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


More information about the Mlir-commits mailing list