Issue 177840
Summary mlir-opt crash on shape.shape_of during --inline pass
Labels new issue
Assignees
Reporter Subway2023
    # Description
mlir-opt version: 22.1.0-rc1

Running mlir-opt with the --inline pass on an MLIR module containing shape.shape_of on a tosa.const tensor triggers an assertion failure in llvm::cast. The crash occurs when the inliner tries to rewrite the shape.shape_of operation, and the operation’s result cannot be cast to the expected TensorType

# Reproduce
location: If the **shape.num_elements** is commented out, the crash no longer occurs.
```
module {
  func.func @main() {
    %0 = emitc.literal "1" : i32
    %1 = "tosa.const"() <{values = dense<1> : tensor<i32>}> : () -> tensor<i32>
    %shape = shape.shape_of %1 : tensor<i32> -> !shape.shape
    %2 = shape.num_elements %shape : !shape.shape -> !shape.size
    return
  }
}
```
```
mlir-opt --inline pass test.mlir
```
```
mlir-opt: /mnt/sdd1/mlir/tool/llvm-project-llvmorg-22.1.0-rc1/llvm/include/llvm/Support/Casting.h:560: decltype(auto) llvm::cast(const From&) [with To = mlir::detail::TypedValue<mlir::TensorType>; From = mlir::OpResult]: 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 and instructions to reproduce the bug.
Stack dump:
0.      Program arguments: /mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt --inline /mnt/sdd1/sbw/mlir/data/genProgram_1229/290237_eb62/mlir_steps/290237_eb62_2.mlir
 #0 0x00005e1f2a0c3e32 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x252fe32)
 #1 0x00005e1f2a0c05af llvm::sys::RunSignalHandlers() (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x252c5af)
 #2 0x00005e1f2a0c06fc SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007a5001c45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #4 0x00007a5001c9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007a5001c9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007a5001c9eb2c pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007a5001c4527e raise ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007a5001c288ff abort ./stdlib/abort.c:81:7
 #9 0x00007a5001c2881b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007a5001c3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
```


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to