<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54928>54928</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR] SCCP assertion crash in forward data flow analysis
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bondhugula
</td>
</tr>
</table>
<pre>
With the git version at afa7c5ddc6bd35213948eb91b434e3c04e6b14bc (Apr 15, 2022) along with the branch op interface for `affine.for` at https://reviews.llvm.org/D123568:
$ bin/mlir-opt -allow-unregistered-dialect test.mlir -pass-pipeline="func.func(sccp)"
```
func @affine_loop_zero_iter(%arg0 : index, %arg1 : index, %arg2 : index) -> i32 {
%s0 = arith.constant 0 : i32
%result = affine.for %i = 0 to 0 iter_args(%si = %s0) -> (i32) {
%sn = arith.addi %si, %si : i32
affine.yield %sn : i32
}
return %result : i32
}
```
```
mlir/lib/Analysis/DataFlowAnalysis.cpp:464: auto (anonymous namespace)::ForwardDataFlowSolver::visitRegionBranchOperation(mlir::RegionBranchOpInterface, ArrayRef<mlir::detail::AbstractLatticeElement *>)::(anonymous class)::operator()(Optional<unsigned int>) const: Assertion `index && "expected valid region index"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
#0 0x0000000000fdf023 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/uday/llvm-project-upstream/build/bin/mlir-opt+0xfdf023)
#1 0x0000000000fdcd5e llvm::sys::RunSignalHandlers() (/home/uday/llvm-project-upstream/build/bin/mlir-opt+0xfdcd5e)
#2 0x0000000000fdf61f SignalHandler(int) Signals.cpp:0:0
#3 0x00007fc4b3e0f3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x143c0)
#4 0x00007fc4b21bc03b raise /build/glibc-sMfBJT/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007fc4b219b859 abort /build/glibc-sMfBJT/glibc-2.31/stdlib/abort.c:81:7
#6 0x00007fc4b219b729 get_sysdep_segment_value /build/glibc-sMfBJT/glibc-2.31/intl/loadmsgcat.c:509:8
#7 0x00007fc4b219b729 _nl_load_domain /build/glibc-sMfBJT/glibc-2.31/intl/loadmsgcat.c:970:34
#8 0x00007fc4b21ad006 (/lib/x86_64-linux-gnu/libc.so.6+0x34006)
#9 0x0000000002056c78 (/home/uday/llvm-project-upstream/build/bin/mlir-opt+0x2056c78)
#10 0x00000000020559ae (anonymous namespace)::ForwardDataFlowSolver::visitRegionSuccessors(mlir::Operation*, llvm::ArrayRef<mlir::RegionSuccessor>, llvm::function_ref<mlir::OperandRange (llvm::Optional<unsigned int>)>) DataFlowAnalysis.cpp:0:0
#11 0x0000000002052635 (anonymous namespace)::ForwardDataFlowSolver::visitOperation(mlir::Operation*) DataFlowAnalysis.cpp:0:0
#12 0x00000000020500dc mlir::detail::ForwardDataFlowAnalysisBase::run(mlir::Operation*) (/home/uday/llvm-project-upstream/build/bin/mlir-opt+0x20500dc)
#13 0x000000000204dcab (anonymous namespace)::SCCP::runOnOperation() SCCP.cpp:0:0
#14 0x0000000002020f73 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/uday/llvm-project-upstream/build/bin/mlir-opt+0x2020f73)
#15 0x0000000002021804 mlir::detail::OpToOpPassAdaptor::runPipeline(llvm::iterator_range<llvm::pointee_iterator<std::unique_ptr<mlir::Pass, std::default_delete<mlir::Pass> >*, mlir::Pass> >, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/uday/llvm-project-upstream/build/bin/mlir-opt+0x2021804)
#16 0x0000000002025fd5 auto mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_8::operator()<std::pair<mlir::Operation*, mlir::AnalysisManager> >(std::pair<mlir::Operation*, mlir::AnalysisManager>&) const Pass.cpp:0:0
#17 0x00000000020272ad std::_Function_handler<void (), mlir::LogicalResult mlir::failableParallelForEach<__gnu_cxx::__normal_iterator<std::pair<mlir::Operation*, mlir::AnalysisManager>*, std::vector<std::pair<mlir::Operation*, mlir::AnalysisManager>, std::allocator<std::pair<mlir::Operation*, mlir::AnalysisManager> > > >, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_8&>(mlir::MLIRContext*, __gnu_cxx::__normal_iterator<std::pair<mlir::Operation*, mlir::AnalysisManager>*, std::vector<std::pair<mlir::Operation*, mlir::AnalysisManager>, std::allocator<std::pair<mlir::Operation*, mlir::AnalysisManager> > > >, __gnu_cxx::__normal_iterator<std::pair<mlir::Operation*, mlir::AnalysisManager>*, std::vector<std::pair<mlir::Operation*, mlir::AnalysisManager>, std::allocator<std::pair<mlir::Operation*, mlir::AnalysisManager> > > >, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_8&)::'lambda'()>::_M_invoke(std::_Any_data const&) Pass.cpp:0:0
#18 0x0000000002026c8c std::_Function_handler<void (), llvm::ThreadPool::createTaskAndFuture(std::function<void ()>)::'lambda'()>::_M_invoke(std::_Any_data const&) Pass.cpp:0:0
#19 0x0000000002028d25 void* llvm::thread::ThreadProxy<std::tuple<llvm::ThreadPool::grow(int)::$_0> >(void*) ThreadPool.cpp:0:0
#20 0x00007fc4b3e03609 start_thread /build/glibc-sMfBJT/glibc-2.31/nptl/pthread_create.c:478:7
#21 0x00007fc4b2298163 __clone /build/glibc-sMfBJT/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97:0
FileCheck error: '<stdin>' is empty.
FileCheck command line: /home/uday/llvm-project-upstream/build/bin/FileCheck /home/uday/llvm-project-upstream/mlir/test/Transforms/sccp-structured.mlir
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWUtv4zgS_jXKhbCht-RDDo6TYLPoRgdJgD0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