Issue 126371
Summary [mlir] Crash when using --test-vector-sink-patterns
Labels mlir
Assignees
Reporter wangyongj1a
    I have the following MLIR program:
test.mlir:
```
module {
  func.func private @func1() {
    %c0_i64 = arith.constant 0 : i64
    %0 = vector.broadcast %c0_i64 : i64 to vector<26x7xi64>
    %1 = builtin.unrealized_conversion_cast %0 : vector<26x7xi64> to !llvm.array<26 x vector<7xi64>>
    %true = arith.constant true
    llvm.cond_br %true, ^bb1, ^bb2
  ^bb1:  // pred: ^bb0
    llvm.br ^bb3(%1 : !llvm.array<26 x vector<7xi64>>)
  ^bb2:  // pred: ^bb0
    llvm.br ^bb3(%1 : !llvm.array<26 x vector<7xi64>>)
  ^bb3(%2: !llvm.array<26 x vector<7xi64>>):  // 2 preds: ^bb1, ^bb2
    llvm.br ^bb4
  ^bb4:  // pred: ^bb3
    return
 }
}
```
The above MLIR program will cause a crash when using the following command:
```
mlir-opt --test-vector-sink-patterns test.mlir
```
And the crash backtrace is:
```
mlir-opt: /data/tmp/v0208/llvm-project/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From&) [with To = mlir::detail::TypedValue<mlir::VectorType>; 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.
Stack dump:
0.      Program arguments: /data/tmp/v0208/llvm-project/build/bin/mlir-opt --test-vector-sink-patterns test.mlir
 #0 0x0000561622b271ef llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x170d1ef)
 #1 0x0000561622b24244 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007fc4381b4420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007fc437c8100b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007fc437c60859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007fc437c60729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007fc437c71fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x0000561622fcdcf7 (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x1bb3cf7)
 #8 0x00005616252a060a mlir::vector::BroadcastOp::fold(mlir::vector::BroadcastOpGenericAdaptor<llvm::ArrayRef<mlir::Attribute>>) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x3e8660a)
 #9 0x00005616252a089d llvm::LogicalResult llvm::detail::UniqueFunctionBase<llvm::LogicalResult, mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&>::CallImpl<mlir::Op<mlir::vector::BroadcastOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::VectorType>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::OneOperand, mlir::OpTrait::OpInvariants, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait, mlir::InferIntRangeInterface::Trait>::getFoldHookFn()::'lambda'(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) const>(void*, mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x3e8689d)
#10 0x000056162530b3f6 mlir::RegisteredOperationName::Model<mlir::vector::BroadcastOp>::foldHook(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x3ef13f6)
#11 0x0000561625e03144 mlir::Operation::fold(llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x49e9144)
#12 0x0000561625e03490 mlir::Operation::fold(llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x49e9490)
#13 0x0000561625c94d71 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#14 0x0000561625c97c6b mlir::applyPatternsGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x487dc6b)
#15 0x0000561626405f22 mlir::applyPatternsGreedily(mlir::Operation*, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (.constprop.0) TestVectorTransforms.cpp:0:0
#16 0x000056162640e8ec (anonymous namespace)::TestVectorSinkPatterns::runOnOperation() TestVectorTransforms.cpp:0:0
#17 0x0000561625bdb261 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x47c1261)
#18 0x0000561625bdb6fa mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x47c16fa)
#19 0x0000561625bdba7e mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::'lambda'(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&)::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#20 0x0000561625bda765 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x47c0765)
#21 0x0000561625bdaf8b mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x47c0f8b)
#22 0x0000561625bdb6fa mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x47c16fa)
#23 0x0000561625bdc234 mlir::PassManager::run(mlir::Operation*) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x47c2234)
#24 0x0000561625bcd34b performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#25 0x0000561625bcddb2 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#26 0x0000561625bce024 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&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#27 0x0000561625cd719e 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) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x48bd19e)
#28 0x0000561625bc4c39 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x47aac39)
#29 0x0000561625bce191 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x47b4191)
#30 0x0000561625bce656 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x47b4656)
#31 0x0000561622a3901b main (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x161f01b)
#32 0x00007fc437c62083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#33 0x0000561622af7aee _start (/data/tmp/v0208/llvm-project/build/bin/mlir-opt+0x16ddaee)
Aborted (core dumped)
```
My git version is 6ff8a06de9ce125023e117014ce4dca8fcc391d7.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to