Issue |
139813
|
Summary |
[MLIR][ODS] mlir-tblgen crash when using `either` to match operand after attribute
|
Labels |
mlir
|
Assignees |
|
Reporter |
xl4624
|
Here is an example of this:
```
def P4HIR_BinOp_AddZero : Pat<
(BinOp BinOpKind_Add, (either $x, (ConstOp P4HIR_IntAttr:$value, $_, $_))),
(replaceWithValue $x),
[(IsZero $value)]
>;
```
The `BinOp` definition above is very similar to `ClangIR`'s `BinOp`, where `BinOpKind` is an `EnumAttr`. When compiling the pattern above `mlir-tblgen` crashes with this stack trace:
```bash
mlir-tblgen: /home/xiaomin/dev/p4mlir/third_party/llvm-project/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From &) [To = mlir::tblgen::NamedTypeConstraint *, From = llvm::PointerUnion<mlir::tblgen::NamedAttribute *, mlir::tblgen::NamedProperty *, mlir::tblgen::NamedTypeConstraint *>]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/xiaomin/dev/p4mlir/install/bin/mlir-tblgen -gen-rewriters -I /home/xiaomin/dev/p4mlir/third_party/p4c/extensions/p4mlir/include/p4mlir/Dialect/P4HIR -I/home/xiaomin/dev/p4mlir/third_party/p4c/build/_deps/gtest-src/googlemock/include -I/home/xiaomin/dev/p4mlir/third_party/p4c/build/_deps/gtest-src/googletest/include -I/usr/include -I/home/xiaomin/dev/p4mlir/third_party/p4c -I/home/xiaomin/dev/p4mlir/third_party/p4c/build -I/home/xiaomin/dev/p4mlir/third_party/p4c/extensions -I/home/xiaomin/dev/p4mlir/install/include -I/home/xiaomin/dev/p4mlir/install/include -I/home/xiaomin/dev/p4mlir/third_party/p4c/extensions/p4mlir/include -I/home/xiaomin/dev/p4mlir/third_party/p4c/build/extensions/p4mlir/include /home/xiaomin/dev/p4mlir/third_party/p4c/extensions/p4mlir/include/p4mlir/Dialect/P4HIR/P4HIR.td --write-if-changed -o extensions/p4mlir/include/p4mlir/Dialect/P4HIR/P4HIR_Patterns.inc -d extensions/p4mlir/include/p4mlir/Dialect/P4HIR/P4HIR_Patterns.inc.d
#0 0x00005cb00f635eb9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/xiaomin/dev/p4mlir/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:799:11
#1 0x00005cb00f63645b PrintStackTraceSignalHandler(void*) /home/xiaomin/dev/p4mlir/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:875:1
#2 0x00005cb00f633a3c llvm::sys::RunSignalHandlers() /home/xiaomin/dev/p4mlir/third_party/llvm-project/llvm/lib/Support/Signals.cpp:105:5
#3 0x00005cb00f636b9a SignalHandler(int) /home/xiaomin/dev/p4mlir/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:415:1
#4 0x0000714ca404def0 (/usr/lib/libc.so.6+0x3def0)
#5 0x0000714ca40a774c (/usr/lib/libc.so.6+0x9774c)
#6 0x0000714ca404ddc0 raise (/usr/lib/libc.so.6+0x3ddc0)
#7 0x0000714ca403557a abort (/usr/lib/libc.so.6+0x2557a)
#8 0x0000714ca40354e3 __assert_perror_fail (/usr/lib/libc.so.6+0x254e3)
#9 0x00005cb00f4c14a4 decltype(auto) llvm::cast<mlir::tblgen::NamedTypeConstraint*, llvm::PointerUnion<mlir::tblgen::NamedAttribute*, mlir::tblgen::NamedProperty*, mlir::tblgen::NamedTypeConstraint*>>(llvm::PointerUnion<mlir::tblgen::NamedAttribute*, mlir::tblgen::NamedProperty*, mlir::tblgen::NamedTypeConstraint*> const&) /home/xiaomin/dev/p4mlir/third_party/llvm-project/llvm/include/llvm/Support/Casting.h:567:43
#10 0x00005cb00f4aa60d (anonymous namespace)::PatternEmitter::emitOperandMatch(mlir::tblgen::DagNode, llvm::StringRef, llvm::StringRef, int, mlir::tblgen::DagLeaf, llvm::StringRef, int, std::optional<int>) /home/xiaomin/dev/p4mlir/third_party/llvm-project/mlir/tools/mlir-tblgen/RewriterGen.cpp:683:9
#11 0x00005cb00f4a966d (anonymous namespace)::PatternEmitter::emitEitherOperandMatch(mlir::tblgen::DagNode, mlir::tblgen::DagNode, llvm::StringRef, int, int&, int) /home/xiaomin/dev/p4mlir/third_party/llvm-project/mlir/tools/mlir-tblgen/RewriterGen.cpp:774:7
#12 0x00005cb00f4a6e4e (anonymous namespace)::PatternEmitter::emitOpMatch(mlir::tblgen::DagNode, llvm::StringRef, int) /home/xiaomin/dev/p4mlir/third_party/llvm-project/mlir/tools/mlir-tblgen/RewriterGen.cpp:612:9
#13 0x00005cb00f4a5251 (anonymous namespace)::PatternEmitter::emitMatch(mlir::tblgen::DagNode, llvm::StringRef, int) /home/xiaomin/dev/p4mlir/third_party/llvm-project/mlir/tools/mlir-tblgen/RewriterGen.cpp:403:5
#14 0x00005cb00f4abe72 (anonymous namespace)::PatternEmitter::emitMatchLogic(mlir::tblgen::DagNode, llvm::StringRef) /home/xiaomin/dev/p4mlir/third_party/llvm-project/mlir/tools/mlir-tblgen/RewriterGen.cpp:958:3
#15 0x00005cb00f4a48f9 (anonymous namespace)::PatternEmitter::emit(llvm::StringRef) /home/xiaomin/dev/p4mlir/third_party/llvm-project/mlir/tools/mlir-tblgen/RewriterGen.cpp:1113:7
#16 0x00005cb00f4a35a9 emitRewriters(llvm::RecordKeeper const&, llvm::raw_ostream&) /home/xiaomin/dev/p4mlir/third_party/llvm-project/mlir/tools/mlir-tblgen/RewriterGen.cpp:1987:56
#17 0x00005cb00f4a2fd1 $_0::operator()(llvm::RecordKeeper const&, llvm::raw_ostream&) const /home/xiaomin/dev/p4mlir/third_party/llvm-project/mlir/tools/mlir-tblgen/RewriterGen.cpp:2006:20
#18 0x00005cb00f4a2fa5 bool std::__invoke_impl<bool, $_0&, llvm::RecordKeeper const&, llvm::raw_ostream&>(std::__invoke_other, $_0&, llvm::RecordKeeper const&, llvm::raw_ostream&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/invoke.h:63:7
#19 0x00005cb00f4a2f45 std::enable_if<is_invocable_r_v<bool, $_0&, llvm::RecordKeeper const&, llvm::raw_ostream&>, bool>::type std::__invoke_r<bool, $_0&, llvm::RecordKeeper const&, llvm::raw_ostream&>($_0&, llvm::RecordKeeper const&, llvm::raw_ostream&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/invoke.h:116:2
#20 0x00005cb00f4a2e6d std::_Function_handler<bool (llvm::RecordKeeper const&, llvm::raw_ostream&), $_0>::_M_invoke(std::_Any_data const&, llvm::RecordKeeper const&, llvm::raw_ostream&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/std_function.h:292:2
#21 0x00005cb00f6bb0ce std::function<bool (llvm::RecordKeeper const&, llvm::raw_ostream&)>::operator()(llvm::RecordKeeper const&, llvm::raw_ostream&) const /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/std_function.h:593:2
#22 0x00005cb00f6b9aa9 mlir::GenInfo::invoke(llvm::RecordKeeper const&, llvm::raw_ostream&) const /home/xiaomin/dev/p4mlir/third_party/llvm-project/mlir/include/mlir/TableGen/GenInfo.h:39:5
#23 0x00005cb00f6b7bd3 mlirTableGenMain(llvm::raw_ostream&, llvm::RecordKeeper const&) /home/xiaomin/dev/p4mlir/third_party/llvm-project/mlir/lib/Tools/mlir-tblgen/MlirTblgenMain.cpp:137:3
#24 0x00005cb00f6bf575 bool std::__invoke_impl<bool, bool (*&)(llvm::raw_ostream&, llvm::RecordKeeper const&), llvm::raw_ostream&, llvm::RecordKeeper const&>(std::__invoke_other, bool (*&)(llvm::raw_ostream&, llvm::RecordKeeper const&), llvm::raw_ostream&, llvm::RecordKeeper const&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/invoke.h:63:7
#25 0x00005cb00f6bf515 std::enable_if<is_invocable_r_v<bool, bool (*&)(llvm::raw_ostream&, llvm::RecordKeeper const&), llvm::raw_ostream&, llvm::RecordKeeper const&>, bool>::type std::__invoke_r<bool, bool (*&)(llvm::raw_ostream&, llvm::RecordKeeper const&), llvm::raw_ostream&, llvm::RecordKeeper const&>(bool (*&)(llvm::raw_ostream&, llvm::RecordKeeper const&), llvm::raw_ostream&, llvm::RecordKeeper const&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/invoke.h:116:2
#26 0x00005cb00f6bf42d std::_Function_handler<bool (llvm::raw_ostream&, llvm::RecordKeeper const&), bool (*)(llvm::raw_ostream&, llvm::RecordKeeper const&)>::_M_invoke(std::_Any_data const&, llvm::raw_ostream&, llvm::RecordKeeper const&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/std_function.h:292:2
#27 0x00005cb00f6c1cae std::function<bool (llvm::raw_ostream&, llvm::RecordKeeper const&)>::operator()(llvm::raw_ostream&, llvm::RecordKeeper const&) const /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/std_function.h:593:2
#28 0x00005cb00f6bfde6 llvm::TableGenMain(char const*, std::function<bool (llvm::raw_ostream&, llvm::RecordKeeper const&)>) /home/xiaomin/dev/p4mlir/third_party/llvm-project/llvm/lib/TableGen/Main.cpp:144:23
#29 0x00005cb00f6b7a4d mlir::MlirTblgenMain(int, char**) /home/xiaomin/dev/p4mlir/third_party/llvm-project/mlir/lib/Tools/mlir-tblgen/MlirTblgenMain.cpp:157:10
#30 0x00005cb00f37ccc2 main /home/xiaomin/dev/p4mlir/third_party/llvm-project/mlir/tools/mlir-tblgen/mlir-tblgen.cpp:27:35
#31 0x0000714ca40376b5 (/usr/lib/libc.so.6+0x276b5)
#32 0x0000714ca4037769 __libc_start_main (/usr/lib/libc.so.6+0x27769)
#33 0x00005cb00f298ac5 _start (/home/xiaomin/dev/p4mlir/install/bin/mlir-tblgen+0x25cac5)
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs