[Mlir-commits] [mlir] [mlir] Improve mlir-query by adding matcher combinators (PR #141423)

Denzel-Brian Budii llvmlistbot at llvm.org
Sat Jun 28 07:26:16 PDT 2025


chios202 wrote:

> I am not sure if the fix can solve the below failure.
> 
> ```
> # RUN: at line 1
> mlir-query /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/test/mlir-query/slice-function-extraction.mlir -c "m getDefinitionsByPredicate(hasOpName(\"memref.store\"),hasOpName(\"memref.alloc\"),true,false,false).extract(\"backward_slice\")" | /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/test/mlir-query/slice-function-extraction.mlir
> # executed command: mlir-query /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/test/mlir-query/slice-function-extraction.mlir -c 'm getDefinitionsByPredicate(hasOpName("memref.store"),hasOpName("memref.alloc"),true,false,false).extract("backward_slice")'
> # .---command stderr------------
> # | PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
> # | Stack dump:
> # | 0.	Program arguments: mlir-query /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/test/mlir-query/slice-function-extraction.mlir -c "m getDefinitionsByPredicate(hasOpName(\"memref.store\"),hasOpName(\"memref.alloc\"),true,false,false).extract(\"backward_slice\")"
> # |  #0 0x00005dbc219e3902 ___interceptor_backtrace /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/../sanitizer_common/sanitizer_common_interceptors.inc:4530:13
> # |  #1 0x00005dbc2eaa5bff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:13
> # |  #2 0x00005dbc2ea9f8f4 llvm::sys::RunSignalHandlers() /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Signals.cpp:0:5
> # |  #3 0x00005dbc2eaa6cfd SignalHandler(int, siginfo_t*, void*) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3
> # |  #4 0x00005dbc21a1754e IsInInterceptorScope /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:78:10
> # |  #5 0x00005dbc21a1754e SignalAction(int, void*, void*) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1167:3
> # |  #6 0x0000774fa0445250 (/lib/x86_64-linux-gnu/libc.so.6+0x45250)
> # |  #7 0x0000774fa04a3f1c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0xa3f1c)
> # |  #8 0x0000774fa044519e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4519e)
> # |  #9 0x0000774fa0428902 abort (/lib/x86_64-linux-gnu/libc.so.6+0x28902)
> # | #10 0x00005dbc219a53ac (/home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/mlir-query+0x2b513ac)
> # | #11 0x00005dbc219a3dbe __sanitizer::Die() /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_termination.cpp:52:5
> # | #12 0x00005dbc219b70d3 (/home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/mlir-query+0x2b630d3)
> # | #13 0x00005dbc2cd20596 (/home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/mlir-query+0xdecc596)
> # | #14 0x00005dbc21a3b35f get /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/include/mlir/Query/Matcher/Marshallers.h:74:65
> # | #15 0x00005dbc21a3b35f matcherMarshallFixedImpl<mlir::query::matcher::PredicateBackwardSliceMatcher<mlir::query::matcher::DynMatcher, mlir::query::matcher::DynMatcher>, mlir::query::matcher::DynMatcher, mlir::query::matcher::DynMatcher, bool, bool, bool, 0UL, 1UL, 2UL, 3UL, 4UL> /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/include/mlir/Query/Matcher/Marshallers.h:250:9
> # | #16 0x00005dbc21a3b35f mlir::query::matcher::VariantMatcher mlir::query::matcher::internal::matcherMarshallFixed<mlir::query::matcher::PredicateBackwardSliceMatcher<mlir::query::matcher::DynMatcher, mlir::query::matcher::DynMatcher>, mlir::query::matcher::DynMatcher, mlir::query::matcher::DynMatcher, bool, bool, bool>(void (*)(), llvm::StringRef, mlir::query::matcher::internal::SourceRange, llvm::ArrayRef<mlir::query::matcher::ParserValue>, mlir::query::matcher::internal::Diagnostics*) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/include/mlir/Query/Matcher/Marshallers.h:263:10
> # | #17 0x00005dbc21a357eb mlir::query::matcher::internal::FixedArgCountMatcherDescriptor::create(mlir::query::matcher::internal::SourceRange, llvm::ArrayRef<mlir::query::matcher::ParserValue>, mlir::query::matcher::internal::Diagnostics*) const /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/include/mlir/Query/Matcher/Marshallers.h:143:5
> # | #18 0x00005dbc2cd1e4a5 mlir::query::matcher::RegistryManager::constructMatcher(mlir::query::matcher::internal::MatcherDescriptor const*, mlir::query::matcher::internal::SourceRange, llvm::StringRef, llvm::ArrayRef<mlir::query::matcher::ParserValue>, mlir::query::matcher::internal::Diagnostics*) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/lib/Query/Matcher/RegistryManager.cpp:0:30
> # | #19 0x00005dbc2cd17c06 mlir::query::matcher::internal::Parser::RegistrySema::actOnMatcherExpression(mlir::query::matcher::internal::MatcherDescriptor const*, mlir::query::matcher::internal::SourceRange, llvm::StringRef, llvm::ArrayRef<mlir::query::matcher::ParserValue>, mlir::query::matcher::internal::Diagnostics*) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/lib/Query/Matcher/Parser.cpp:574:3
> # | #20 0x00005dbc2cd148c3 get /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/libcxx_install_msan/include/c++/v1/__memory/shared_ptr.h:631:70
> # | #21 0x00005dbc2cd148c3 operator bool /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/libcxx_install_msan/include/c++/v1/__memory/shared_ptr.h:646:75
> # | #22 0x00005dbc2cd148c3 isNull /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/include/mlir/Query/Matcher/VariantValue.h:59:33
> # | #23 0x00005dbc2cd148c3 mlir::query::matcher::internal::Parser::parseMatcherExpressionImpl(mlir::query::matcher::internal::Parser::TokenInfo const&, mlir::query::matcher::internal::Parser::TokenInfo const&, std::__1::optional<mlir::query::matcher::internal::MatcherDescriptor const*>, mlir::query::matcher::VariantValue*) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/lib/Query/Matcher/Parser.cpp:473:14
> # | #24 0x00005dbc2cd133cb mlir::query::matcher::internal::Parser::parseIdentifierPrefixImpl(mlir::query::matcher::VariantValue*) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/lib/Query/Matcher/Parser.cpp:346:10
> # | #25 0x00005dbc2cd17eba mlir::query::matcher::internal::Parser::parseExpression(llvm::StringRef&, mlir::query::matcher::Registry const&, llvm::StringMap<mlir::query::matcher::VariantValue, llvm::MallocAllocator> const*, mlir::query::matcher::VariantValue*, mlir::query::matcher::internal::Diagnostics*) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/lib/Query/Matcher/Parser.cpp:0:15
> # | #26 0x00005dbc2cd18970 mlir::query::matcher::internal::Parser::parseMatcherExpression(llvm::StringRef&, mlir::query::matcher::Registry const&, llvm::StringMap<mlir::query::matcher::VariantValue, llvm::MallocAllocator> const*, mlir::query::matcher::internal::Diagnostics*) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/lib/Query/Matcher/Parser.cpp:0:0
> # | #27 0x00005dbc2cd0cc72 has_value /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/libcxx_install_msan/include/c++/v1/optional:360:82
> # | #28 0x00005dbc2cd0cc72 operator bool /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/libcxx_install_msan/include/c++/v1/optional:824:84
> # | #29 0x00005dbc2cd0cc72 mlir::query::QueryParser::doParse() /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/lib/Query/QueryParser.cpp:181:10
> # | #30 0x00005dbc2cd0dd19 ~QueryParser /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/lib/Query/QueryParser.h:54:23
> # | #31 0x00005dbc2cd0dd19 ~QueryParser /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/lib/Query/QueryParser.h:23:7
> # | #32 0x00005dbc2cd0dd19 mlir::query::QueryParser::parse(llvm::StringRef, mlir::query::QuerySession const&) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/lib/Query/QueryParser.cpp:199:3
> # | #33 0x00005dbc2cd02c0e mlir::query::parse(llvm::StringRef, mlir::query::QuerySession const&) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/lib/Query/Query.cpp:23:3
> # | #34 0x00005dbc2719976f operator-> /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:204:34
> # | #35 0x00005dbc2719976f mlir::mlirQueryMain(int, char**, mlir::MLIRContext&, mlir::query::matcher::Registry const&) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/lib/Tools/mlir-query/MlirQueryMain.cpp:96:24
> # | #36 0x00005dbc21a2761e main /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/mlir/tools/mlir-query/mlir-query.cpp:79:17
> # | #37 0x0000774fa042a3b8 (/lib/x86_64-linux-gnu/libc.so.6+0x2a3b8)
> # | #38 0x0000774fa042a47b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a47b)
> # | #39 0x00005dbc219981e5 _start (/home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/mlir-query+0x2b441e5)
> # `-----------------------------
> ```
> 
> I will go ahead and revert the PR according to https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy
> 
> You can fix this patch and send the patch again.

I've tested this fix locally using msan build. I have opened a PR for it: https://github.com/llvm/llvm-project/pull/146156 

https://github.com/llvm/llvm-project/pull/141423


More information about the Mlir-commits mailing list