Files
TheRock/compiler/amd-llvm/mlir/test/Transforms/test-symbol-dce.mlir
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

136 lines
4.0 KiB
MLIR

// RUN: mlir-opt -allow-unregistered-dialect %s -symbol-dce -split-input-file -verify-diagnostics | FileCheck %s
// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="builtin.module(builtin.module(symbol-dce))" -split-input-file | FileCheck %s --check-prefix=NESTED
// Check that trivially dead and trivially live non-nested cases are handled.
// CHECK-LABEL: module attributes {test.simple}
module attributes {test.simple} {
// CHECK-NOT: func private @dead_private_function
func.func private @dead_private_function()
// CHECK-NOT: func nested @dead_nested_function
func.func nested @dead_nested_function()
// CHECK: func private @live_private_function
func.func private @live_private_function()
// CHECK: func nested @live_nested_function
func.func nested @live_nested_function()
// CHECK: func @public_function
func.func @public_function() {
"foo.return"() {uses = [@live_private_function, @live_nested_function]} : () -> ()
}
}
// -----
// Check that we don't DCE nested symbols if they are used.
// CHECK-LABEL: module attributes {test.nested}
module attributes {test.nested} {
// CHECK: module @public_module
module @public_module {
// CHECK-NOT: func nested @dead_nested_function
func.func nested @dead_nested_function()
// CHECK: func private @private_function
func.func private @private_function()
// CHECK: func nested @nested_function
func.func nested @nested_function() {
"foo.return"() {uses = [@private_function]} : () -> ()
}
}
"live.user"() {uses = [@public_module::@nested_function]} : () -> ()
}
// -----
// Check that we don't DCE symbols if we can't prove that the top-level symbol
// table that we are running on is hidden from above.
// NESTED-LABEL: module attributes {test.no_dce_non_hidden_parent}
module attributes {test.no_dce_non_hidden_parent} {
// NESTED: module @public_module
module @public_module {
// NESTED: func nested @nested_function
func.func nested @nested_function()
}
// NESTED: module @nested_module
module @nested_module attributes { sym_visibility = "nested" } {
// NESTED: func nested @nested_function
func.func nested @nested_function()
}
// Only private modules can be assumed to be hidden.
// NESTED: module @private_module
module @private_module attributes { sym_visibility = "private" } {
// NESTED-NOT: func nested @nested_function
func.func nested @nested_function()
}
"live.user"() {uses = [@nested_module, @private_module]} : () -> ()
}
// -----
module {
func.func private @private_symbol()
// expected-error@+1 {{contains potentially unknown symbol table}}
"foo.possibly_unknown_symbol_table"() ({
}) : () -> ()
}
// -----
// Check that unknown symbol references are OK.
module {
// CHECK-NOT: func private @dead_private_function
func.func private @dead_private_function()
// CHECK: func private @live_private_function
func.func private @live_private_function()
// CHECK: "live.user"() {uses = [@live_private_function]} : () -> ()
"live.user"() {uses = [@live_private_function]} : () -> ()
// CHECK: "live.user"() {uses = [@unknown_symbol]} : () -> ()
"live.user"() {uses = [@unknown_symbol]} : () -> ()
}
// -----
// Check that we don't DCE nested symbols if they are nested inside region
// without SymbolTable.
// CHECK-LABEL: module attributes {test.nested_nosymboltable_region}
module attributes { test.nested_nosymboltable_region } {
"test.one_region_op"() ({
"test.symbol_scope"() ({
// CHECK: func nested @nfunction
func.func nested @nfunction() {
return
}
func.call @nfunction() : () -> ()
"test.finish"() : () -> ()
}) : () -> ()
"test.finish"() : () -> ()
}) : () -> ()
}
// -----
// CHECK-LABEL: module attributes {test.nested_nosymboltable_region_notcalled}
// CHECK-NOT: @nested
// CHECK: @main
module attributes { test.nested_nosymboltable_region_notcalled } {
"test.one_region_op"() ({
module {
func.func nested @nested() { return }
func.func @main() { return }
}
"test.finish"() : () -> ()
}) : () -> ()
}