Issue 240307
Summary [MLIR] Crash in `-arith-expand` when processing arith.flush_denormals with dynamic-shaped tensors
Labels mlir
Assignees
Reporter frida-albrecht
    The `--arith-expand=include-flush-denormals=true` pass crashes with an assertion failure when lowering `arith.flush_denormals` on a tensor with dynamic shape.

test commit: [5fe5e53](https://github.com/llvm/llvm-project/commit/5fe5e53cff518bb81e2debaff4747c8b9bac130b)

test case:
```mlir
module {
  func.func @func_897010(%arg0: memref<*xcomplex<f64>>, %arg1: tensor<*xbf16>) -> memref<*xcomplex<f64>> {
 %0 = arith.flush_denormals %arg1 fastmath<contract> : tensor<*xbf16>
 return %arg0 : memref<*xcomplex<f64>>
  }
}
```

Step to reproduce:
```
mlir-opt test.mlir --arith-expand=include-flush-denormals=true
```

Crash backtrace:
```
mlir-opt: /home/llvm-project/llvm-project-latest/mlir/lib/IR/BuiltinAttributes.cpp:1219: static mlir::DenseElementsAttr mlir::DenseTypedElementsAttr::getRaw(mlir::ShapedType, llvm::ArrayRef<char>): Assertion `type.hasStaticShape() && "type must have static shape"' 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: mlir-opt test.mlir --arith-expand=include-flush-denormals=true
 #0 0x000055e05864f949 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x1fe3949)
 #1 0x000055e05864c14c llvm::sys::RunSignalHandlers() (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x1fe014c)
 #2 0x000055e05864c2b6 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f4a46b06520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f4a46b5a9bc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969bc)
 #5 0x00007f4a46b06476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007f4a46aec7f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007f4a46aec71b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007f4a46afde96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x000055e0610f3d80 mlir::DenseTypedElementsAttr::getRaw(mlir::ShapedType, llvm::ArrayRef<char>) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xaa87d80)
#10 0x000055e0610fa350 mlir::DenseElementsAttr::get(mlir::ShapedType, llvm::ArrayRef<mlir::Attribute>) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xaa8e350)
#11 0x000055e05f76d039 createAPIntConst(mlir::Location, mlir::Type, llvm::APInt const&, mlir::PatternRewriter&) ExpandOps.cpp:0:0
#12 0x000055e05f76ece1 (anonymous namespace)::FlushDenormalsOpConverter::matchAndRewrite(mlir::arith::FlushDenormalsOp, mlir::PatternRewriter&) const ExpandOps.cpp:0:0
#13 0x000055e060e66f1c mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>)::'lambda'()::operator()() const PatternApplicator.cpp:0:0
#14 0x000055e060e685fa mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa7fc5fa)
#15 0x000055e060e130eb (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*) DialectConversion.cpp:0:0
#16 0x000055e060e135a4 mlir::OperationConverter::convert(mlir::Operation*, bool) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa7a75a4)
#17 0x000055e060e1da86 mlir::OperationConverter::applyConversion(llvm::ArrayRef<mlir::Operation*>) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa7b1a86)
#18 0x000055e060e1f0bf applyConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode) DialectConversion.cpp:0:0
#19 0x000055e060e1f276 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa7b3276)
#20 0x000055e05f769509 (anonymous namespace)::ArithExpandOpsPass::runOnOperation() ExpandOps.cpp:0:0
#21 0x000055e060ecef49 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa862f49)
#22 0x000055e060ecf224 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa863224)
#23 0x000055e060ed0e72 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa864e72)
#24 0x000055e060ed1e49 mlir::PassManager::run(mlir::Operation*) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa865e49)
#25 0x000055e058719ea6 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#26 0x000055e05871b45e processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#27 0x000055e05871b6a1 llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, 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::MemoryBufferRef, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#28 0x000055e061201f2d 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::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xab95f2d)
#29 0x000055e05871539a mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#30 0x000055e05871bce1 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x20afce1)
#31 0x000055e05871bf34 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x20aff34)
#32 0x000055e0585f3d8c main (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x1f87d8c)
#33 0x00007f4a46aedd90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#34 0x00007f4a46aede40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#35 0x000055e05862f1e5 _start (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x1fc31e5)
Aborted (core dumped)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to