| Issue |
97857
|
| Summary |
[MLIR][linalg] Parser crashes on transpose
|
| Labels |
mlir
|
| Assignees |
|
| Reporter |
IanWood1
|
My mlir lsp crashed when working with linalg.transpose. The issue I was can be reproduced with `mlir-opt`, which crashes when parsing this mlir:
```
module {
func.func private @transpose(%arg0 : tensor<10x10xi32>){
%0 = linalg.transpose permutation = [0, 1]
}
}
```
This crash occurs for both `linalg.transpose` and `linalg.broadcast` ops. It looks like the reason is that this occurs is that the call to `buildIdentityRegion` implicitly requires that the op has at least 1 bb arg. https://github.com/llvm/llvm-project/blob/c2fbc701aaf826e2015a5dcab36e3ba792e7da7f/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp#L1780 Defined here https://github.com/llvm/llvm-project/blob/c2fbc701aaf826e2015a5dcab36e3ba792e7da7f/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp#L1737-L1744
Trace:
```
STLExtras.h:1272: ReferenceT llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<const
mlir::Value *, mlir::OpOperand *, mlir::detail::OpResultImpl *>, mlir::Value, mlir::Value, mlir::Value>::operator[](size_t) const [DerivedT = mlir::ValueRange, BaseT = llvm::PointerUnion<const mlir::Value *, mlir::OpOperand *, mlir::detail::OpResultImpl *>, T = mlir::Value, PointerT = mlir::Value, ReferenceT = mlir::Value]: Assertion `Index < size() && "invalid index for value
range"' failed.
#0 0x00005ef82a40f887 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
#1 0x00005ef82a40dad0 llvm::sys::RunSignalHandlers() /iree/third_party/llvm-project/llvm/lib/Support/Signals.cpp:106:18
#2 0x00005ef82a41020a SignalHandler(int) /iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
#3 0x0000709d4f442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000709d4f4969fc __pthread_kill_implementation ./nptl/./nptl/pthread_kill.c:44:76
#5 0x0000709d4f4969fc __pthread_kill_internal ./nptl/./nptl/pthread_kill.c:78:10
#6 0x0000709d4f4969fc pthread_kill ./nptl/./nptl/pthread_kill.c:89:10
#7 0x0000709d4f442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x0000709d4f4287f3 abort ./stdlib/./stdlib/abort.c:81:7
#9 0x0000709d4f42871b _nl_load_domain ./intl/./intl/loadmsgcat.c:1177:9
#10 0x0000709d4f439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00005ef82abe42c1 (./build/RelWithDebInfo/llvm-project/bin/mlir-opt+0x443d2c1)
#12 0x00005ef82aafc726 mlir::OpBuilder::InsertPoint::isSet() const /iree/third_party/llvm-project/mlir/include/mlir/IR/Builders.h:339:40
#13 0x00005ef82aafc726 mlir::OpBuilder::restoreInsertionPoint(mlir::OpBuilder::InsertPoint) /iree/third_party/llvm-project/mlir/include/mlir/IR/Builders.h:393:12
#14 0x00005ef82aafc726 mlir::OpBuilder::InsertionGuard::~InsertionGuard() /iree/third_party/llvm-project/mlir/include/mlir/IR/Builders.h:357:18
#15 0x00005ef82aafc726 buildGenericRegion(mlir::OpBuilder&, mlir::Location, mlir::Region&, mlir::ValueRange, mlir::ValueRange, llvm::function_ref<void (mlir::OpBuilder&, mlir::Location, mlir
::ValueRange)>) /iree/third_party/llvm-project/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp:916:1
#16 0x00005ef82ab04619 buildIdentityRegion(mlir::OpBuilder&, mlir::Location, mlir::Region&, mlir::ValueRange, mlir::ValueRange) /iree/third_party/llvm-project/mlir/lib/Dialect/L
inalg/IR/LinalgOps.cpp:0:3
#17 0x00005ef82ab04619 mlir::linalg::TransposeOp::parse(mlir::OpAsmParser&, mlir::OperationState&) /iree/third_party/llvm-project/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp:1780:3
#18 0x00005ef82e35e2cb llvm::LogicalResult::failed() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#19 0x00005ef82e35e2cb llvm::ParseResult::operator bool() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:124:53
#20 0x00005ef82e35e2cb (anonymous namespace)::CustomOpAsmParser::parseOperation(mlir::OperationState&) /iree/third_party/llvm-project/mlir/lib/AsmParser/Parser.cpp:1521:9
#21 0x00005ef82e35e2cb (anonymous namespace)::OperationParser::parseCustomOperation(llvm::ArrayRef<std::tuple<llvm::StringRef, unsigned int, llvm::SMLoc> >) /iree/third_party/ll
vm-project/mlir/lib/AsmParser/Parser.cpp:2017:19
#22 0x00005ef82e35e2cb (anonymous namespace)::OperationParser::parseOperation() /iree/third_party/llvm-project/mlir/lib/AsmParser/Parser.cpp:1174:10
#23 0x00005ef82e367f80 llvm::LogicalResult::failed() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#24 0x00005ef82e367f80 llvm::ParseResult::operator bool() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:124:53
#25 0x00005ef82e367f80 (anonymous namespace)::OperationParser::parseBlockBody(mlir::Block*) /iree/third_party/llvm-project/mlir/lib/AsmParser/Parser.cpp:2296:9
#26 0x00005ef82e367f80 (anonymous namespace)::OperationParser::parseBlock(mlir::Block*&) /iree/third_party/llvm-project/mlir/lib/AsmParser/Parser.cpp:2226:12
#27 0x00005ef82e365f22 llvm::LogicalResult::failed() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#28 0x00005ef82e365f22 llvm::ParseResult::operator bool() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:124:53
#29 0x00005ef82e365f22 (anonymous namespace)::OperationParser::parseRegionBody(mlir::Region&, llvm::SMLoc, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /iree/third_party/l
lvm-project/mlir/lib/AsmParser/Parser.cpp:2184:7
#30 0x00005ef82e365f22 (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /iree/third_party/llvm-project/mlir/
lib/AsmParser/Parser.cpp:2121:7
#31 0x00005ef82e3644a9 llvm::LogicalResult::failed() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#32 0x00005ef82e3644a9 llvm::ParseResult::operator bool() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:124:53
#33 0x00005ef82e3644a9 (anonymous namespace)::CustomOpAsmParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /iree/third_party/llvm-project/mli
r/lib/AsmParser/Parser.cpp:1785:9
#34 0x00005ef82e3644ec (anonymous namespace)::CustomOpAsmParser::parseOptionalRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /iree/third_party/llvm-pro
ject/mlir/lib/AsmParser/Parser.cpp:1796:5
#35 0x00005ef82e3227ef std::_Optional_base_impl<llvm::ParseResult, std::_Optional_base<llvm::ParseResult, true, true> >::_M_is_engaged() const /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../.
./../include/c++/11/optional:433:58
#36 0x00005ef82e3227ef std::optional<llvm::ParseResult>::has_value() const /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/optional:945:22
#37 0x00005ef82e3227ef mlir::OptionalParseResult::has_value() const /iree/third_party/llvm-project/mlir/include/mlir/IR/OpDefinition.h:49:40
#38 0x00005ef82e3227ef mlir::function_interface_impl::parseFunctionOp(mlir::OpAsmParser&, mlir::OperationState&, bool, mlir::StringAttr, llvm::function_ref<mlir::Type (mlir::Builder&, llvm::
ArrayRef<mlir::Type>, llvm::ArrayRef<mlir::Type>, mlir::function_interface_impl::VariadicFlag, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)>, mlir::Strin
gAttr, mlir::StringAttr) /iree/third_party/llvm-project/mlir/lib/Interfaces/FunctionImplementation.cpp:234:19
#39 0x00005ef82a939348 mlir::func::FuncOp::parse(mlir::OpAsmParser&, mlir::OperationState&) /iree/third_party/llvm-project/mlir/lib/Dialect/Func/IR/FuncOps.cpp:203:10
#40 0x00005ef82e35e2cb llvm::LogicalResult::failed() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#41 0x00005ef82e35e2cb llvm::ParseResult::operator bool() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:124:53
#42 0x00005ef82e35e2cb (anonymous namespace)::CustomOpAsmParser::parseOperation(mlir::OperationState&) /iree/third_party/llvm-project/mlir/lib/AsmParser/Parser.cpp:1521:9
#43 0x00005ef82e35e2cb (anonymous namespace)::OperationParser::parseCustomOperation(llvm::ArrayRef<std::tuple<llvm::StringRef, unsigned int, llvm::SMLoc> >) /iree/third_party/ll
vm-project/mlir/lib/AsmParser/Parser.cpp:2017:19
#44 0x00005ef82e35e2cb (anonymous namespace)::OperationParser::parseOperation() /iree/third_party/llvm-project/mlir/lib/AsmParser/Parser.cpp:1174:10
#45 0x00005ef82e367f80 llvm::LogicalResult::failed() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#46 0x00005ef82e367f80 llvm::ParseResult::operator bool() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:124:53
#47 0x00005ef82e367f80 (anonymous namespace)::OperationParser::parseBlockBody(mlir::Block*) /iree/third_party/llvm-project/mlir/lib/AsmParser/Parser.cpp:2296:9
#48 0x00005ef82e367f80 (anonymous namespace)::OperationParser::parseBlock(mlir::Block*&) /iree/third_party/llvm-project/mlir/lib/AsmParser/Parser.cpp:2226:12
#49 0x00005ef82e365d79 llvm::LogicalResult::failed() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#50 0x00005ef82e365d79 llvm::ParseResult::operator bool() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:124:53
#51 0x00005ef82e365d79 (anonymous namespace)::OperationParser::parseRegionBody(mlir::Region&, llvm::SMLoc, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /iree/third_party/l
lvm-project/mlir/lib/AsmParser/Parser.cpp:2184:7
#52 0x00005ef82e365d79 (anonymous namespace)::OperationParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /iree/third_party/llvm-project/mlir/
lib/AsmParser/Parser.cpp:2121:7
#53 0x00005ef82e3644a9 llvm::LogicalResult::failed() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#54 0x00005ef82e3644a9 llvm::ParseResult::operator bool() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:124:53
#55 0x00005ef82e3644a9 (anonymous namespace)::CustomOpAsmParser::parseRegion(mlir::Region&, llvm::ArrayRef<mlir::OpAsmParser::Argument>, bool) /iree/third_party/llvm-project/mli
r/lib/AsmParser/Parser.cpp:1785:9
#56 0x00005ef82cb8f249 llvm::LogicalResult::failed() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#57 0x00005ef82cb8f249 llvm::ParseResult::operator bool() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:124:53
#58 0x00005ef82cb8f249 mlir::ModuleOp::parse(mlir::OpAsmParser&, mlir::OperationState&) /iree/build/RelWithDebInfo/llvm-project/tools/mlir/include/mlir/IR/BuiltinOps.cpp.inc:293
:7
#59 0x00005ef82e35e2cb llvm::LogicalResult::failed() const /iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs