Closed
Description
Such test will result a crash:
// mlir-opt -canonicalize test.mlir
module {
func.func @extract() -> i64 {
%c0 = arith.constant 0 : index
%cst = arith.constant dense_resource<__Constant_5_output_0> : tensor<1xi64>
%extracted = tensor.extract %cst[%c0] : tensor<1xi64>
return %extracted : i64
}
}
{-#
dialect_resources: {
builtin: {
__Constant_5_output_0: "0x080000000200000000000000"
}
}
#-}
backtrace:
ElementsAttr does not provide iteration facilities for type `mlir::Attribute`, see attribute: dense_resource<__Constant_5_output_0> : tensor<1xi64>
invalid `T` for ElementsAttr::getValues
UNREACHABLE executed at /home/mls/community/llvm-project/mlir/include/mlir/IR/BuiltinAttributeInterfaces.h:306!
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 extract.mlir --canonicalize
#0 0x0000561ff1cc8e9c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/mls/community/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:22
#1 0x0000561ff1cc92bd PrintStackTraceSignalHandler(void*) /home/mls/community/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
#2 0x0000561ff1cc670d llvm::sys::RunSignalHandlers() /home/mls/community/llvm-project/llvm/lib/Support/Signals.cpp:105:20
#3 0x0000561ff1cc8734 SignalHandler(int) /home/mls/community/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
#4 0x00007f82b34a5520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x00007f82b34f99fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#6 0x00007f82b34f99fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#7 0x00007f82b34f99fc pthread_kill ./nptl/pthread_kill.c:89:10
#8 0x00007f82b34a5476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#9 0x00007f82b348b7f3 abort ./stdlib/abort.c:81:7
#10 0x0000561ff1d11238 bindingsErrorHandler(void*, char const*, bool) /home/mls/community/llvm-project/llvm/lib/Support/ErrorHandling.cpp:223:55
#11 0x0000561ff3dc0a8c _ZNK4mlir12ElementsAttr11value_beginINS_9AttributeEEENSt9enable_ifIXoosrSt7is_sameIS2_T_E5valuentsrSt10is_base_ofIS2_S5_E5valueENS_6detail20ElementsAttrIteratorIS5_EEE4typeEv /home/mls/community/llvm-project/mlir/include/mlir/IR/BuiltinAttributeInterfaces.h:302:31
#12 0x0000561ff3d9cc9b _ZNK4mlir12ElementsAttr9getValuesINS_9AttributeEEENSt9enable_ifIXoosrSt7is_sameIS2_T_E5valuentsrSt10is_base_ofIS2_S5_E5valueENS_6detail17ElementsAttrRangeINS9_20ElementsAttrIteratorIS5_EEEEE4typeEv /home/mls/community/build-llvm/tools/mlir/include/mlir/IR/BuiltinAttributeInterfaces.h.inc:184:64
#13 0x0000561ff5bba948 mlir::tensor::ExtractOp::fold(mlir::tensor::ExtractOpGenericAdaptor<llvm::ArrayRef<mlir::Attribute>>) /home/mls/community/llvm-project/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp:1169:57
#14 0x0000561ff5ba3280 llvm::LogicalResult mlir::Op<mlir::tensor::ExtractOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::Type>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::AtLeastNOperands<1u>::Impl, mlir::OpTrait::OpInvariants, mlir::OpAsmOpInterface::Trait, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait, mlir::InferTypeOpInterface::Trait>::foldSingleResultHook<mlir::tensor::ExtractOp>(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) /home/mls/community/llvm-project/mlir/include/mlir/IR/OpDefinition.h:1907:42
#15 0x0000561ff5b9e7ce mlir::Op<mlir::tensor::ExtractOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::Type>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::AtLeastNOperands<1u>::Impl, mlir::OpTrait::OpInvariants, mlir::OpAsmOpInterface::Trait, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait, mlir::InferTypeOpInterface::Trait>::getFoldHookFn()::'lambda'(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&)::operator()(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) const /home/mls/community/llvm-project/mlir/include/mlir/IR/OpDefinition.h:1881:14
#16 0x0000561ff5bb028a llvm::LogicalResult llvm::detail::UniqueFunctionBase<llvm::LogicalResult, mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&>::CallImpl<mlir::Op<mlir::tensor::ExtractOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::Type>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::AtLeastNOperands<1u>::Impl, mlir::OpTrait::OpInvariants, mlir::OpAsmOpInterface::Trait, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait, mlir::InferTypeOpInterface::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>&) /home/mls/community/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:223:3
#17 0x0000561ff1ea53b2 llvm::unique_function<llvm::LogicalResult (mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) const>::operator()(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) const /home/mls/community/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:414:3
#18 0x0000561ff5b99338 mlir::RegisteredOperationName::Model<mlir::tensor::ExtractOp>::foldHook(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) /home/mls/community/llvm-project/mlir/include/mlir/IR/OperationSupport.h:538:41
#19 0x0000561ff7bddfa9 mlir::OperationName::foldHook(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) const /home/mls/community/llvm-project/mlir/include/mlir/IR/OperationSupport.h:266:3
#20 0x0000561ff7bd6180 mlir::Operation::fold(llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) /home/mls/community/llvm-project/mlir/lib/IR/Operation.cpp:636:16
#21 0x0000561ff7bd636d mlir::Operation::fold(llvm::SmallVectorImpl<mlir::OpFoldResult>&) /home/mls/community/llvm-project/mlir/lib/IR/Operation.cpp:666:14
#22 0x0000561ff794e44c (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() /home/mls/community/llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:493:20
#23 0x0000561ff794fe60 (anonymous namespace)::RegionPatternRewriteDriver::simplify(bool*) &&::'lambda2'()::operator()() const /home/mls/community/llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:874:28
#24 0x0000561ff79510c0 void llvm::function_ref<void ()>::callback_fn<(anonymous namespace)::RegionPatternRewriteDriver::simplify(bool*) &&::'lambda2'()>(long) /home/mls/community/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:40
#25 0x0000561ff1cec178 llvm::function_ref<void ()>::operator()() const /home/mls/community/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:62
#26 0x0000561ff7950e09 void mlir::MLIRContext::executeAction<(anonymous namespace)::GreedyPatternRewriteIteration, long&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, long&) /home/mls/community/llvm-project/mlir/include/mlir/IR/MLIRContext.h:281:3
#27 0x0000561ff7950156 (anonymous namespace)::RegionPatternRewriteDriver::simplify(bool*) && /home/mls/community/llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:887:3
#28 0x0000561ff79502b3 mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) /home/mls/community/llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:919:55
#29 0x0000561ff1ed4c34 mlir::applyPatternsAndFoldGreedily(mlir::Operation*, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) /home/mls/community/llvm-project/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h:159:37
#30 0x0000561ff788cbdc (anonymous namespace)::Canonicalizer::runOnOperation() /home/mls/community/llvm-project/mlir/lib/Transforms/Canonicalizer.cpp:63:37
#31 0x0000561ff7830b61 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::'lambda0'()::operator()() const /home/mls/community/llvm-project/mlir/lib/Pass/Pass.cpp:523:57
#32 0x0000561ff7834808 void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::'lambda0'()>(long) /home/mls/community/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:40
#33 0x0000561ff1cec178 llvm::function_ref<void ()>::operator()() const /home/mls/community/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:62
#34 0x0000561ff783c2d9 void mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pass&) /home/mls/community/llvm-project/mlir/include/mlir/IR/MLIRContext.h:281:3
#35 0x0000561ff7830f85 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /home/mls/community/llvm-project/mlir/lib/Pass/Pass.cpp:532:23
#36 0x0000561ff7831266 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /home/mls/community/llvm-project/mlir/lib/Pass/Pass.cpp:592:15
#37 0x0000561ff7833174 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /home/mls/community/llvm-project/mlir/lib/Pass/Pass.cpp:905:40
#38 0x0000561ff7832fcc mlir::PassManager::run(mlir::Operation*) /home/mls/community/llvm-project/mlir/lib/Pass/Pass.cpp:885:69
#39 0x0000561ff7823811 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) /home/mls/community/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:412:13
#40 0x0000561ff7823ef7 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) /home/mls/community/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:477:26
#41 0x0000561ff78244af 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&)::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /home/mls/community/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:560:25
#42 0x0000561ff7825631 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&) /home/mls/community/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:52
#43 0x0000561ff79bf009 llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /home/mls/community/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#44 0x0000561ff79be89a 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) /home/mls/community/llvm-project/mlir/lib/Support/ToolUtilities.cpp:27:30
#45 0x0000561ff7824648 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) /home/mls/community/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:563:31
#46 0x0000561ff7824941 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) /home/mls/community/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:604:13
#47 0x0000561ff7824b38 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) /home/mls/community/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:620:21
#48 0x0000561ff1c22ad8 main /home/mls/community/llvm-project/mlir/tools/mlir-opt/mlir-opt.cpp:321:0
#49 0x00007f82b348cd90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#50 0x00007f82b348ce40 call_init ./csu/../csu/libc-start.c:128:20
#51 0x00007f82b348ce40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#52 0x0000561ff1c22565 _start (/home/mls/community/build-llvm/bin/mlir-opt+0x1f02565)
Aborted (core dumped)