<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116350>116350</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR]-test-print-dominance triggers Assertion Failure `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"'
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
xisang0
</td>
</tr>
</table>
<pre>
Test on commit: https://github.com/llvm/llvm-project/commit/6548b6354d1d990e1c98736f5e7c3de876bedc8e
steps to reproduce:
```
mlir-opt test.mlir --test-print-dominance
```
test case:
```
module {
func.func @reduce_prod_constant(){
%const = "tosa.const"() <{value = dense<[[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]], [[13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24]]]> : tensor<2x3x4xi32>}> : () -> tensor<2x3x4xi32>
%0 = tosa.reduce_prod %const {axis = 1 : i32} : (tensor<2x3x4xi32>) -> tensor<2x1x4xi32>
return
}
}
```
crash trace:
```
mlir-opt: /home/workdir/llvm-project-19/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = mlir::SymbolOpInterface, From = mlir::Operation]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: ./mlir-opt /home/workdir/test.mlir --test-print-dominance
#0 0x00005f0d59f003b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./mlir-opt+0x10723b8)
#1 0x00005f0d59efdede llvm::sys::RunSignalHandlers() (./mlir-opt+0x106fede)
#2 0x00005f0d59f00dc8 SignalHandler(int) Signals.cpp:0:0
#3 0x00007c6f24651520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007c6f246a59fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007c6f24651476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007c6f246377f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007c6f2463771b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007c6f24648e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00005f0d5c5a2e0f decltype(auto) llvm::cast<mlir::SymbolOpInterface, mlir::Operation>(mlir::Operation*) (./mlir-opt+0x3714e0f)
#10 0x00005f0d5d051e62 (anonymous namespace)::TestDominancePass::runOnOperation() TestDominance.cpp:0:0
#11 0x00005f0d5d17c6df mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x42ee6df)
#12 0x00005f0d5d17cec2 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x42eeec2)
#13 0x00005f0d5d17f66e mlir::PassManager::run(mlir::Operation*) (./mlir-opt+0x42f166e)
#14 0x00005f0d5d178192 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#15 0x00005f0d5d177dfb llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#16 0x00005f0d5d221ae5 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (./mlir-opt+0x4393ae5)
#17 0x00005f0d5d172ff2 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (./mlir-opt+0x42e4ff2)
#18 0x00005f0d5d1732a3 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x42e52a3)
#19 0x00005f0d5d1734b2 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x42e54b2)
#20 0x00005f0d59edf5d7 main (./mlir-opt+0x10515d7)
#21 0x00007c6f24638d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#22 0x00007c6f24638e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#23 0x00005f0d59edf145 _start (./mlir-opt+0x1051145)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWF1v27wV_jXMDRGDIvV54QvHqbECDRo0wW4NijySuUqkRlJ9k38_kHIcy7Hb-sXeDVuRUpZ4-JznfFIid061GmCJsjuU3d_w0e-MXb4ox3VLbmojX5fP4Dw2GgvT98ojtsI77weH2ArRDaKbVvndWC-E6RHddN2Pt8vtYM0_QHhEN_uldJNnaVnnLEtlIquKQCKqsmB5k0EhmISyyGuQogRE7hFZOQ-Dw95gC4M1chQQlMYplJP9X7ztO2VvzeCxB-cX4Q7f3obft4NV2t9K0yvNtYCzq4MgFtxdhjdy7ACj4m66x7gZtViEAaOUWAjctoHjVhjtPN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