Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

negative nodes for pattern matching #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

bollu
Copy link
Owner

@bollu bollu commented Dec 10, 2021

I'm not sure we really need this power, but it seems interesting to know how to implement. It lets us express things like

there is store operation in this BB by matching for
[=? (var bb) (const entry), (in-bb x bb) ~ (=? (kind x (const "store")))

bollu added a commit that referenced this pull request Feb 4, 2022
_druid@siddharth-lean ~/phd/mlir-hoopl-rete/build/bin ‹master›
╰─$ LLVM_SYMBOLIZER_PATH=`which llvm-symbolizer-7` ./rete --bench-pdl ../../test/simple.mlir
rete: /home/siddu_druid/phd/mlir-hoopl-rete/llvm-project/mlir/lib/Rewrite/ByteCode.cpp:489: void (anonymous namespace)::Generator::generate(mlir::ModuleOp): Assertion `matcherFunc && rewriterModule && "invalid PDL Interpreter module"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ./rete --bench-pdl ../../test/simple.mlir
 #0 0x000000000049ad43 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./rete+0x49ad43)
 #1 0x00000000004989fe llvm::sys::RunSignalHandlers() (./rete+0x4989fe)
 #2 0x000000000049b386 SignalHandler(int) (./rete+0x49b386)
 #3 0x00007f5d7e0a5ef0 __restore_rt (/nix/store/563528481rvhc5kxwipjmg6rqrl95mdx-glibc-2.33-56/lib/libpthread.so.0+0x12ef0)
 #4 0x00007f5d7dbc7baa __GI_raise (/nix/store/563528481rvhc5kxwipjmg6rqrl95mdx-glibc-2.33-56/lib/libc.so.6+0x3bbaa)
 #5 0x00007f5d7dbb2523 __GI_abort (/nix/store/563528481rvhc5kxwipjmg6rqrl95mdx-glibc-2.33-56/lib/libc.so.6+0x26523)
 #6 0x00007f5d7dbb241f _nl_load_domain.cold.0 (/nix/store/563528481rvhc5kxwipjmg6rqrl95mdx-glibc-2.33-56/lib/libc.so.6+0x2641f)
 #7 0x00007f5d7dbc05f2 (/nix/store/563528481rvhc5kxwipjmg6rqrl95mdx-glibc-2.33-56/lib/libc.so.6+0x345f2)
 #8 0x0000000001226e2d mlir::detail::PDLByteCode::PDLByteCode(mlir::ModuleOp, llvm::StringMap<std::function<mlir::LogicalResult (llvm::ArrayRef<mlir::PDLValue>, mlir::ArrayAttr, mlir::PatternRewriter&)>, llvm::MallocAllocator>, llvm::StringMap<std::function<void (llvm::ArrayRef<mlir::PDLValue>, mlir::ArrayAttr, mlir::PatternRewriter&, mlir::PDLResultList&)>, llvm::MallocAllocator>) (./rete+0x1226e2d)
 #9 0x000000000121ef05 std::_MakeUniq<mlir::detail::PDLByteCode>::__single_object std::make_unique<mlir::detail::PDLByteCode, mlir::ModuleOp&, llvm::StringMap<std::function<mlir::LogicalResult (llvm::ArrayRef<mlir::PDLValue>, mlir::ArrayAttr, mlir::PatternRewriter&)>, llvm::MallocAllocator>, llvm::StringMap<std::function<void (llvm::ArrayRef<mlir::PDLValue>, mlir::ArrayAttr, mlir::PatternRewriter&, mlir::PDLResultList&)>, llvm::MallocAllocator> >(mlir::ModuleOp&, llvm::StringMap<std::function<mlir::LogicalResult (llvm::ArrayRef<mlir::PDLValue>, mlir::ArrayAttr, mlir::PatternRewriter&)>, llvm::MallocAllocator>&&, llvm::StringMap<std::function<void (llvm::ArrayRef<mlir::PDLValue>, mlir::ArrayAttr, mlir::PatternRewriter&, mlir::PDLResultList&)>, llvm::MallocAllocator>&&) (./rete+0x121ef05)
<Up>[1]    23174 abort      LLVM_SYMBOLIZER_PATH=`which llvm-symbolizer-7` ./rete --bench-pdl
bollu added a commit that referenced this pull request Feb 4, 2022
╭─siddu_druid@siddharth-lean ~/phd/mlir-hoopl-rete/test ‹master●›
╰─$ mlir-opt pdl-simple.mlir -allow-unregistered-dialect -test-pdl-bytecode-pass                                                                                                                                                          148 ↵
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 pdl-simple.mlir -allow-unregistered-dialect -test-pdl-bytecode-pass
 #0 0x00000000008be623 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/siddu_druid/phd/mlir-hoopl-rete/llvm-project/build/bin/mlir-opt+0x8be623)
 #1 0x00000000008bc2de llvm::sys::RunSignalHandlers() (/home/siddu_druid/phd/mlir-hoopl-rete/llvm-project/build/bin/mlir-opt+0x8bc2de)
 #2 0x00000000008bec16 SignalHandler(int) (/home/siddu_druid/phd/mlir-hoopl-rete/llvm-project/build/bin/mlir-opt+0x8bec16)
 #3 0x00007fad2398d730 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12730)
 #4 0x0000000000faa046 std::enable_if<!(std::is_convertible<mlir::ValueRange&, mlir::Operation*>::value), void>::type mlir::ResultRange::replaceAllUsesWith<mlir::ValueRange&>(mlir::ValueRange&) (/home/siddu_druid/phd/mlir-hoopl-rete/llvm-pr
oject/build/bin/mlir-opt+0xfaa046)
 #5 0x0000000001862fac mlir::RewriterBase::replaceOp(mlir::Operation*, mlir::ValueRange) (/home/siddu_druid/phd/mlir-hoopl-rete/llvm-project/build/bin/mlir-opt+0x1862fac)
 #6 0x00000000018d6ad5 (anonymous namespace)::ByteCodeExecutor::execute(mlir::PatternRewriter&, llvm::SmallVectorImpl<mlir::detail::PDLByteCode::MatchResult>*, llvm::Optional<mlir::Location>) (/home/siddu_druid/phd/mlir-hoopl-rete/llvm-proj
ect/build/bin/mlir-opt+0x18d6ad5)
 #7 0x00000000018d8ec1 mlir::detail::PDLByteCode::rewrite(mlir::PatternRewriter&, mlir::detail::PDLByteCode::MatchResult const&, mlir::detail::PDLByteCodeMutableState&) const (/home/siddu_druid/phd/mlir-hoopl-rete/llvm-project/build/bin/mli
r-opt+0x18d8ec1)
 #8 0x00000000018f15b6 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResu
lt (mlir::Pattern const&)>) (/home/siddu_druid/phd/mlir-hoopl-rete/llvm-project/build/bin/mlir-opt+0x18f15b6)
 #9 0x00000000017aab4c mlir::applyPatternsAndFoldGreedily(llvm::MutableArrayRef<mlir::Region>, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig) (/home/siddu_druid/phd/mlir-hoopl-rete/llvm-project/build/bin/mlir-opt+0x17aab4c
)
signed int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/siddu_druid/phd/mlir-hoopl-rete/llvm-project/build/bin/mlir-opt+0x174f404)
+0x1725bf0)
try&, llvm::ThreadPool*) (/home/siddu_druid/phd/mlir-hoopl-rete/llvm-project/build/bin/mlir-opt+0x1723dfa)
ol, bool, bool) (/home/siddu_druid/phd/mlir-hoopl-rete/llvm-project/build/bin/mlir-opt+0x1723aaa)
[2]    27957 segmentation fault  mlir-opt pdl-simple.mlir -allow-unregistered-dialect -test-pdl-bytecode-pass
╭─siddu_druid@siddharth-lean ~/phd/mlir-hoopl-rete/test ‹master●›
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant