From bdfb113d8d765bdf4554a2b30ae909b93f26aeea Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Thu, 22 Aug 2024 14:55:03 +0200 Subject: [PATCH] Fix picking ByDeclaration strategy Due to refactorings, the ByInstruction strategy was always picked. Fix that and only pick ByInstruction if there are opcodes that need it. --- include/llvm-dialects/Dialect/OpMap.h | 4 ++++ lib/Dialect/Visitor.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/llvm-dialects/Dialect/OpMap.h b/include/llvm-dialects/Dialect/OpMap.h index 543251d..1d18bfd 100644 --- a/include/llvm-dialects/Dialect/OpMap.h +++ b/include/llvm-dialects/Dialect/OpMap.h @@ -339,6 +339,10 @@ template class OpMap final { m_dialectOps.empty(); } + bool emptyCoreOpcodes() const { + return m_coreOpcodes.empty(); + } + // -------------------------------------------------------------------------- // Iterator definitions. // -------------------------------------------------------------------------- diff --git a/lib/Dialect/Visitor.cpp b/lib/Dialect/Visitor.cpp index 69e9e4f..9fbdd0d 100644 --- a/lib/Dialect/Visitor.cpp +++ b/lib/Dialect/Visitor.cpp @@ -185,8 +185,8 @@ VisitorBase::VisitorBase(VisitorTemplate &&templ) : m_strategy(templ.m_strategy), m_projections(std::move(templ.m_projections)) { if (m_strategy == VisitorStrategy::Default) { - m_strategy = templ.m_opMap.empty() ? VisitorStrategy::ByFunctionDeclaration - : VisitorStrategy::ByInstruction; + m_strategy = templ.m_opMap.emptyCoreOpcodes() ? VisitorStrategy::ByFunctionDeclaration + : VisitorStrategy::ByInstruction; } BuildHelper helper(*this, templ.m_handlers);