Issue 128275
Summary [mlir] Crash when using --test-expand-math
Labels mlir
Assignees
Reporter wangyongj1a
    I have the following MLIR program:
test.mlir:
```
module {
  func.func @func1() {
    %idx0 = index.constant 0
    %cst_90 = arith.constant 1.000000e+00 : f32
    %from_elements_92 = tensor.from_elements %cst_90, %cst_90 : tensor<2xf32>
    %cast_93 = tensor.cast %from_elements_92 : tensor<2xf32> to tensor<?xf32>
    %112 = math.ceil %cast_93 : tensor<?xf32>
    %dim_233 = tensor.dim %112, %idx0 : tensor<?xf32>
 vector.print %dim_233 : index
    return
  }
}
```
The above MLIR program will cause a crash when using the following command:
```
mlir-opt --test-expand-math test.mlir
```
And the crash backtrace is:
```
mlir-opt: /data/tmp/v0222/llvm-project/mlir/lib/IR/BuiltinAttributes.cpp:1346: static mlir::DenseElementsAttr mlir::DenseIntOrFPElementsAttr::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.
Stack dump:
0.      Program arguments: /data/tmp/v0222/llvm-project/build/bin/mlir-opt --test-expand-math test.mlir
 #0 0x0000561287c6aa5f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/tmp/v0222/llvm-project/build/bin/mlir-opt+0x167ba5f)
 #1 0x0000561287c67ab4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007f761d95c420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f761d42900b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f761d408859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007f761d408729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007f761d419fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x000056128ad70688 mlir::DenseIntOrFPElementsAttr::getRaw(mlir::ShapedType, llvm::ArrayRef<char>) (/data/tmp/v0222/llvm-project/build/bin/mlir-opt+0x4781688)
 #8 0x000056128ad809f6 mlir::DenseElementsAttr::get(mlir::ShapedType, llvm::ArrayRef<mlir::Attribute>) (/data/tmp/v0222/llvm-project/build/bin/mlir-opt+0x47919f6)
 #9 0x000056128b49c1fd createFloatConst(mlir::Location, mlir::Type, llvm::APFloat, mlir::OpBuilder&) ExpandPatterns.cpp:0:0
#10 0x000056128b49c4d4 createFloatConst(mlir::Location, mlir::Type, double, mlir::OpBuilder&) ExpandPatterns.cpp:0:0
#11 0x000056128b49d80a convertCeilOp(mlir::math::CeilOp, mlir::PatternRewriter&) ExpandPatterns.cpp:0:0
#12 0x000056128a7c7e9f mlir::detail::OpOrInterfaceRewritePatternBase<mlir::math::CeilOp>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data/tmp/v0222/llvm-project/build/bin/mlir-opt+0x41d8e9f)
#13 0x000056128e6e7cb8 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&)>) (/data/tmp/v0222/llvm-project/build/bin/mlir-opt+0x80f8cb8)
#14 0x000056128acc03f1 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#15 0x000056128acc331c mlir::applyPatternsGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data/tmp/v0222/llvm-project/build/bin/mlir-opt+0x46d431c)
#16 0x000056128ae97072 (anonymous namespace)::TestExpandMathPass::runOnOperation() TestExpandMath.cpp:0:0
#17 0x000056128ac0bd31 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/tmp/v0222/llvm-project/build/bin/mlir-opt+0x461cd31)
#18 0x000056128ac0c1da mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/tmp/v0222/llvm-project/build/bin/mlir-opt+0x461d1da)
#19 0x000056128ac0cd74 mlir::PassManager::run(mlir::Operation*) (/data/tmp/v0222/llvm-project/build/bin/mlir-opt+0x461dd74)
#20 0x000056128abfe3cb performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#21 0x000056128abfee32 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
#22 0x000056128abff0a4 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
#23 0x000056128ad0395e 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/v0222/llvm-project/build/bin/mlir-opt+0x471495e)
#24 0x000056128abf5cb9 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/tmp/v0222/llvm-project/build/bin/mlir-opt+0x4606cb9)
#25 0x000056128abff211 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v0222/llvm-project/build/bin/mlir-opt+0x4610211)
#26 0x000056128abff6d6 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v0222/llvm-project/build/bin/mlir-opt+0x46106d6)
#27 0x0000561287b8603b main (/data/tmp/v0222/llvm-project/build/bin/mlir-opt+0x159703b)
#28 0x00007f761d40a083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#29 0x0000561287c3b37e _start (/data/tmp/v0222/llvm-project/build/bin/mlir-opt+0x164c37e)
Aborted (core dumped)
```
My git version is 93b2e47f12649bd33b99b88f25beb277a181274a.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to