| Issue |
177824
|
| Summary |
mlir-opt --remove-dead-values crashes on tensor.collapse_shape with DenseElementsAttr
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Subway2023
|
# Description
Running mlir-opt with the --remove-dead-values pass on a module containing tensor.collapse_shape applied to a DenseElementsAttr triggers an assertion failure
# Reproduce
mlir-opt version: 22.1.0-rc1
location: If the **tensor.collapse_shape** is commented out, the crash no longer occurs.
```
module {
func.func @main() {
%0 = arith.constant dense<0> : tensor<i32>
scf.execute_region -> tensor<i32> {
scf.yield %0 : tensor<i32>
}
%1 = arith.constant dense<0> : tensor<2xi32>
%collapsed = tensor.collapse_shape %1 [] : tensor<2xi32> into tensor<i32>
return
}
}
```
```
mlir-opt --remove-dead-values test.mlir
```
```
mlir-opt: /mnt/sdd1/mlir/tool/llvm-project-llvmorg-22.1.0-rc1/mlir/lib/IR/BuiltinAttributes.cpp:1246: mlir::DenseElementsAttr mlir::DenseElementsAttr::reshape(mlir::ShapedType): Assertion `newType.getNumElements() == curType.getNumElements() && "expected the same number of elements"' 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: /mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt --remove-dead-values /mnt/sdd1/sbw/mlir/data/genProgram_1224/250348_7ef3/mlir_steps/250348_7ef3_5.mlir
#0 0x000063d8fbcc7e32 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x252fe32)
#1 0x000063d8fbcc45af llvm::sys::RunSignalHandlers() (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x252c5af)
#2 0x000063d8fbcc46fc SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x000076fd10c45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#4 0x000076fd10c9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x000076fd10c9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x000076fd10c9eb2c pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x000076fd10c4527e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x000076fd10c288ff abort ./stdlib/abort.c:81:7
#9 0x000076fd10c2881b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x000076fd10c3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#11 0x000063d90383492f mlir::DenseElementsAttr::reshape(mlir::ShapedType) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0xa09c92f)
#12 0x000063d90310db5d mlir::OpFoldResult mlir::foldReshapeOp<mlir::tensor::CollapseShapeOp, mlir::tensor::ExpandShapeOp>(mlir::tensor::CollapseShapeOp, llvm::ArrayRef<mlir::Attribute>) TensorOps.cpp:0:0
#13 0x000063d9030b26d2 llvm::LogicalResult llvm::detail::UniqueFunctionBase<llvm::LogicalResult, mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&>::CallImpl<mlir::Op<mlir::tensor::CollapseShapeOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::TensorType>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::OneOperand, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::OpAsmOpInterface::Trait, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait>::getFoldHookFn()::'lambda'(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) const>(void*, mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x991a6d2)
#14 0x000063d9030c25b1 mlir::RegisteredOperationName::Model<mlir::tensor::CollapseShapeOp>::foldHook(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x992a5b1)
#15 0x000063d9038dd074 mlir::Operation::fold(llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0xa145074)
#16 0x000063d9036ad62a mlir::dataflow::SparseConstantPropagation::visitOperation(mlir::Operation*, llvm::ArrayRef<mlir::dataflow::Lattice<mlir::dataflow::ConstantValue> const*>, llvm::ArrayRef<mlir::dataflow::Lattice<mlir::dataflow::ConstantValue>*>) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9f1562a)
#17 0x000063d9036dc450 mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::visitOperation(mlir::Operation*) (.part.0) SparseAnalysis.cpp:0:0
#18 0x000063d9036e11bb mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::initializeRecursively(mlir::Operation*) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9f491bb)
#19 0x000063d9036e1833 mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::initializeRecursively(mlir::Operation*) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9f49833)
#20 0x000063d9036e1833 mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::initializeRecursively(mlir::Operation*) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9f49833)
#21 0x000063d90365d0fd mlir::DataFlowSolver::initializeAndRun(mlir::Operation*) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9ec50fd)
#22 0x000063d9036d7946 mlir::dataflow::RunLivenessAnalysis::RunLivenessAnalysis(mlir::Operation*) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9f3f946)
#23 0x000063d9034398df mlir::dataflow::RunLivenessAnalysis& mlir::Pass::getAnalysis<mlir::dataflow::RunLivenessAnalysis>() (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9ca18df)
#24 0x000063d9034402a0 (anonymous namespace)::RemoveDeadValues::runOnOperation() RemoveDeadValues.cpp:0:0
#25 0x000063d903567756 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9dcf756)
#26 0x000063d903567a8e mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9dcfa8e)
#27 0x000063d9035681e2 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9dd01e2)
#28 0x000063d903569400 mlir::PassManager::run(mlir::Operation*) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x9dd1400)
#29 0x000063d8fbd8e767 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#30 0x000063d8fbd8f4ea 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
#31 0x000063d903937731 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) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0xa19f731)
#32 0x000063d8fbd868d0 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
#33 0x000063d8fbd8fb70 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x25f7b70)
#34 0x000063d8fbd8fda9 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x25f7da9)
#35 0x000063d8fbbc1023 main (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x2429023)
#36 0x000076fd10c2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#37 0x000076fd10c2a28b call_init ./csu/../csu/libc-start.c:128:20
#38 0x000076fd10c2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
#39 0x000063d8fbca6405 _start (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x250e405)
Aborted (core dumped)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs