Closed

Description
Similar to #74461, but with different content in the unreachable block.
git version: 6e90f13
system: Ubuntu 20.04.6 LTS (Focal Fossa)
reproduced with: mlir-opt --canonicalize a.mlir
a.mlir:
func.func private @func1() {
%false = arith.constant false
%c0 = arith.constant 0 : index
cf.cond_br %false, ^bb1, ^bb2
^bb1: // pred: ^bb0
omp.parallel {
omp.wsloop for (%arg0) : index = (%c0) to (%c0) step (%c0) {
%189 = llvm.intr.stacksave : !llvm.ptr
llvm.br ^bb1
^bb1: // pred: ^bb0
llvm.br ^bb2
^bb2: // pred: ^bb1
omp.yield
}
omp.terminator
}
cf.br ^bb2
^bb2: // pred: ^bb0
return
}
trace:
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /data1/bin-dev/llvm-project/build/bin/mlir-opt --canonicalize a.mlir
#0 0x000055b186889e4f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x1684e4f)
#1 0x000055b186886ea4 SignalHandler(int) Signals.cpp:0:0
#2 0x00007fd721788420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x000055b1896c0d6b mlir::SuccessorRange::SuccessorRange(mlir::Block*) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x44bbd6b)
#4 0x000055b18942f71f llvm::po_iterator<mlir::Block*, llvm::SmallPtrSet<mlir::Block*, 8u>, false, llvm::GraphTraits<mlir::Block*>>::traverseChild() (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x422a71f)
#5 0x000055b18942fdeb llvm::iterator_range<llvm::po_iterator<mlir::Block*, llvm::SmallPtrSet<llvm::GraphTraits<mlir::Block*>::NodeRef, 8u>, false, llvm::GraphTraits<mlir::Block*>>> llvm::post_order<mlir::Block*>(mlir::Block* const&) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x422adeb)
#6 0x000055b1897a8feb mlir::RewriterBase::eraseOp(mlir::Operation*)::'lambda0'(mlir::Operation*)::operator()(mlir::Operation*) const (.isra.0) PatternMatch.cpp:0:0
#7 0x000055b1897a911e mlir::RewriterBase::eraseOp(mlir::Operation*)::'lambda0'(mlir::Operation*)::operator()(mlir::Operation*) const (.isra.0) PatternMatch.cpp:0:0
#8 0x000055b1897a9d36 mlir::RewriterBase::eraseOp(mlir::Operation*) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x45a4d36)
#9 0x000055b1897a9c09 mlir::RewriterBase::eraseBlock(mlir::Block*) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x45a4c09)
#10 0x000055b18965cdbb mlir::eraseUnreachableBlocks(mlir::RewriterBase&, llvm::MutableArrayRef<mlir::Region>) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x4457dbb)
#11 0x000055b18966535a mlir::simplifyRegions(mlir::RewriterBase&, llvm::MutableArrayRef<mlir::Region>) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x446035a)
#12 0x000055b1896455b1 mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x44405b1)
#13 0x000055b1895adcda (anonymous namespace)::Canonicalizer::runOnOperation() Canonicalizer.cpp:0:0
#14 0x000055b18958e85e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x438985e)
#15 0x000055b18958ed3a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x4389d3a)
#16 0x000055b18958f504 mlir::PassManager::run(mlir::Operation*) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x438a504)
#17 0x000055b1895801f3 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#18 0x000055b189581774 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#19 0x000055b189581924 mlir::LogicalResult llvm::function_ref<mlir::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
#20 0x000055b18967df14 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x4478f14)
#21 0x000055b189579d87 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x4374d87)
#22 0x000055b189581a71 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x437ca71)
#23 0x000055b189581ef6 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x437cef6)
#24 0x000055b1867c05d3 main (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x15bb5d3)
#25 0x00007fd721254083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#26 0x000055b18685993e _start (/data1/bin-dev/llvm-project/build/bin/mlir-opt+0x165493e)
Segmentation fault (core dumped)