Issue 128346
Summary [MLIR]`--test-ir-visitors --mlir-print-assume-verified` triggers Assertion failure `!region.empty() && "unexpected empty region"'
Labels mlir
Assignees
Reporter xisang0
    Test on commit: https://github.com/llvm/llvm-project/commit/d866005f6928a2a97e67866bedb26139d8cc27d9
steps to reproduce:
```
mlir-opt test.mlir --test-ir-visitors --mlir-print-assume-verified
```
test case:
```
#map = affine_map<(d0, d1, d2, d3, d4) -> (d0, d3, d4)>
#map1 = affine_map<(d0, d1, d2, d3, d4) -> (d0, d1, d2)>
module {
  func.func @test_fft2d_with_local_bound(%arg0: tensor<1x4x8xf32>, %arg1: tensor<1x4x8xf32>) -> (tensor<1x4x8xf32>, tensor<1x4x8xf32>) {
    %cst = arith.constant 8.000000e+00 : f32
 %cst_0 = arith.constant 4.000000e+00 : f32
    %cst_1 = arith.constant 6.28318548 : f32
    %c8 = arith.constant 8 : index
    %c4 = arith.constant 4 : index
    %cst_2 = arith.constant 0.000000e+00 : f32
 %0 = tensor.empty() : tensor<1x4x8xf32>
    %1 = linalg.fill ins(%cst_2 : f32) outs(%0 : tensor<1x4x8xf32>) -> tensor<1x4x8xf32>
    %2 = tensor.empty() : tensor<1x4x8xf32>
    %3 = linalg.fill ins(%cst_2 : f32) outs(%2 : tensor<1x4x8xf32>) -> tensor<1x4x8xf32>
    %4:2 = linalg.generic {indexing_maps = [#map, #map, #map1, #map1], iterator_types = ["parallel", "parallel", "parallel", "reduction", "reduction"]} ins(%arg0, %arg1 : tensor<1x4x8xf32>, tensor<1x4x8xf32>) outs(%1, %3 : tensor<1x4x8xf32>, tensor<1x4x8xf32>) {
      ^bb0(%in: f32, %in_3: f32, %out: f32, %out_4: f32):
        %5 = linalg.index 1 : index
        %6 = linalg.index 2 : index
        %7 = linalg.index 3 : index
        %8 = linalg.index 4 : index
        %9 = index.mul %7, %5
        %10 = index.mul %8, %6
 %11 = index.remu %9, %c4
        %12 = index.remu %10, %c8
        %13 = arith.index_castui %11 : index to i32
        %14 = arith.uitofp %13 : i32 to f32
        %15 = arith.index_castui %12 : index to i32
        %16 = arith.uitofp %15 : i32 to f32
        %17 = arith.divf %14, %cst_0 : f32
 %18 = arith.divf %16, %cst : f32
        %19 = arith.addf %17, %18 : f32
        %20 = arith.mulf %19, %cst_1 : f32
        %21 = math.cos %20 : f32
        %22 = math.sin %20 : f32
        %23 = arith.mulf %in, %21 : f32
        %24 = arith.mulf %in_3, %22 : f32
        %25 = arith.addf %23, %24 : f32
        %26 = arith.mulf %in_3, %21 : f32
        %27 = arith.mulf %in, %22 : f32
        %28 = arith.subf %26, %27 : f32
 %29 = arith.addf %out, %25 : f32
        %30 = arith.addf %out_4, %28 : f32
        linalg.yield %29, %30 : f32, f32
    } -> (tensor<1x4x8xf32>, tensor<1x4x8xf32>)

    return %4#0, %4#1 : tensor<1x4x8xf32>, tensor<1x4x8xf32>
  }
}
```
crash trace:
```
mlir-opt: /home/workdir/llvm-project-19/mlir/include/mlir/IR/OpDefinition.h:897: Block *mlir::OpTrait::SingleBlock<mlir::linalg::GenericOp>::getBody(unsigned int) [ConcreteType = mlir::linalg::GenericOp]: Assertion `!region.empty() && "unexpected empty region"' 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-ir-visitors --mlir-print-assume-verified
 #0 0x000060f44a2513e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./mlir-opt+0x11393e8)
 #1 0x000060f44a24ef0e llvm::sys::RunSignalHandlers() (./mlir-opt+0x1136f0e)
 #2 0x000060f44a251df8 SignalHandler(int) Signals.cpp:0:0
 #3 0x000070761fe61520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000070761feb59fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000070761fe61476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000070761fe477f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000070761fe4771b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x000070761fe58e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x000060f44aaff07b mlir::linalg::detail::LinalgOpTrait<mlir::linalg::GenericOp>::getRegionInputArgs() (./mlir-opt+0x19e707b)
#10 0x000060f44aafeeda mlir::linalg::GenericOp::getAsmBlockArgumentNames(mlir::Region&, llvm::function_ref<void (mlir::Value, llvm::StringRef)>) (./mlir-opt+0x19e6eda)
#11 0x000060f44adbdeae mlir::detail::OpAsmOpInterfaceInterfaceTraits::Model<mlir::linalg::GenericOp>::getAsmBlockArgumentNames(mlir::detail::OpAsmOpInterfaceInterfaceTraits::Concept const*, mlir::Operation*, mlir::Region&, llvm::function_ref<void (mlir::Value, llvm::StringRef)>) (./mlir-opt+0x1ca5eae)
#12 0x000060f44d2233aa mlir::detail::AsmStateImpl::AsmStateImpl(mlir::Operation*, mlir::OpPrintingFlags const&, llvm::DenseMap<mlir::Operation*, std::pair<unsigned int, unsigned int>, llvm::DenseMapInfo<mlir::Operation*, void>, llvm::detail::DenseMapPair<mlir::Operation*, std::pair<unsigned int, unsigned int>>>*) (./mlir-opt+0x410b3aa)
#13 0x000060f44d207fa6 mlir::AsmState::AsmState(mlir::Operation*, mlir::OpPrintingFlags const&, llvm::DenseMap<mlir::Operation*, std::pair<unsigned int, unsigned int>, llvm::DenseMapInfo<mlir::Operation*, void>, llvm::detail::DenseMapPair<mlir::Operation*, std::pair<unsigned int, unsigned int>>>*, mlir::FallbackAsmResourceMap*) (./mlir-opt+0x40effa6)
#14 0x000060f44d213ab5 mlir::Block::printAsOperand(llvm::raw_ostream&, bool) (./mlir-opt+0x40fbab5)
#15 0x000060f44d7a8633 printBlock(mlir::Block*) TestVisitors.cpp:0:0
#16 0x000060f44d7ad1bc void llvm::function_ref<void (mlir::Block*)>::callback_fn<testNoSkipErasureCallbacks(mlir::Operation*)::$_1>(long, mlir::Block*) TestVisitors.cpp:0:0
#17 0x000060f44cc4d25e void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Block*)>, mlir::WalkOrder) (./mlir-opt+0x3b3525e)
#18 0x000060f44cc4d243 void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Block*)>, mlir::WalkOrder) (./mlir-opt+0x3b35243)
#19 0x000060f44d7a8336 (anonymous namespace)::TestIRVisitorsPass::runOnOperation() TestVisitors.cpp:0:0
#20 0x000060f44d15015f mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x403815f)
#21 0x000060f44d1508e2 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x40388e2)
#22 0x000060f44d15306e mlir::PassManager::run(mlir::Operation*) (./mlir-opt+0x403b06e)
#23 0x000060f44d14ba1b performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#24 0x000060f44d14b673 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
#25 0x000060f44d1f3de5 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+0x40dbde5)
#26 0x000060f44d1452d2 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (./mlir-opt+0x402d2d2)
#27 0x000060f44d145583 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x402d583)
#28 0x000060f44d145792 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x402d792)
#29 0x000060f44a230607 main (./mlir-opt+0x1118607)
#30 0x000070761fe48d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#31 0x000070761fe48e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#32 0x000060f44a230175 _start (./mlir-opt+0x1118175)
Aborted (core dumped)
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to