diff --git a/jlm/hls/backend/rvsdg2rhls/rvsdg2rhls.cpp b/jlm/hls/backend/rvsdg2rhls/rvsdg2rhls.cpp index 0af759b36..f7150771e 100644 --- a/jlm/hls/backend/rvsdg2rhls/rvsdg2rhls.cpp +++ b/jlm/hls/backend/rvsdg2rhls/rvsdg2rhls.cpp @@ -488,8 +488,13 @@ dump_ref(llvm::RvsdgModule & rhls, const util::filepath & path) << "\n"; } ::llvm::LLVMContext ctx; - jlm::util::StatisticsCollector statisticsCollector; - auto jm2 = llvm::RvsdgToIpGraphConverter::CreateAndConvertModule(*reference, statisticsCollector); + util::StatisticsCollector statisticsCollector; + auto sequentializer = + llvm::CreateIdempotentRegionTreeSequentializer(reference->Rvsdg().GetRootRegion()); + auto jm2 = llvm::RvsdgToIpGraphConverter::CreateAndConvertModule( + *reference, + statisticsCollector, + sequentializer); auto lm2 = llvm::IpGraphToLlvmConverter::CreateAndConvertModule(*jm2, ctx); std::error_code EC; ::llvm::raw_fd_ostream os(path.to_str(), EC); diff --git a/jlm/llvm/Makefile.sub b/jlm/llvm/Makefile.sub index 13c1c1a33..5693285a5 100644 --- a/jlm/llvm/Makefile.sub +++ b/jlm/llvm/Makefile.sub @@ -4,6 +4,7 @@ libllvm_SOURCES = \ jlm/llvm/backend/dot/DotWriter.cpp \ jlm/llvm/backend/IpGraphToLlvmConverter.cpp \ + jlm/llvm/backend/RegionSequentializer.cpp \ jlm/llvm/backend/RvsdgToIpGraphConverter.cpp \ \ jlm/llvm/frontend/ControlFlowRestructuring.cpp \ @@ -137,10 +138,12 @@ libllvm_HEADERS = \ jlm/llvm/ir/aggregation.hpp \ jlm/llvm/backend/dot/DotWriter.hpp \ jlm/llvm/backend/IpGraphToLlvmConverter.hpp \ + jlm/llvm/backend/RegionSequentializer.hpp \ jlm/llvm/backend/RvsdgToIpGraphConverter.hpp \ libllvm_TESTS += \ tests/jlm/llvm/backend/dot/DotWriterTests \ + tests/jlm/llvm/backend/ExhaustiveSequentializerTests \ tests/jlm/llvm/backend/IpGraphToLlvmConverterTests \ tests/jlm/llvm/backend/RvsdgToIpGraphConverterTests \ tests/jlm/llvm/frontend/llvm/LoadTests \ diff --git a/jlm/llvm/backend/RegionSequentializer.cpp b/jlm/llvm/backend/RegionSequentializer.cpp new file mode 100644 index 000000000..bea7c0e8e --- /dev/null +++ b/jlm/llvm/backend/RegionSequentializer.cpp @@ -0,0 +1,205 @@ +/* + * Copyright 2025 Nico Reißmann + * See COPYING for terms of redistribution. + */ + +#include +#include +#include +#include + +namespace jlm::llvm +{ + +RegionSequentializer::~RegionSequentializer() noexcept = default; + +RegionSequentializer::RegionSequentializer(rvsdg::Region & region) + : Region_(®ion) +{} + +ExhaustiveRegionSequentializer::ExhaustiveRegionSequentializer(rvsdg::Region & region) + : RegionSequentializer(region) +{ + util::HashSet visited; + std::vector sequentializedNodes; + ComputeSequentializations(region, visited, sequentializedNodes); +} + +void +ExhaustiveRegionSequentializer::ComputeNextSequentialization() +{ + if (HasMoreSequentializations()) + CurrentSequentialization_++; + else + CurrentSequentialization_ = 0; +} + +Sequentialization +ExhaustiveRegionSequentializer::GetSequentialization() +{ + if (!HasMoreSequentializations()) + ComputeNextSequentialization(); + + return Sequentializations_[CurrentSequentialization_]; +} + +bool +ExhaustiveRegionSequentializer::HasMoreSequentializations() const noexcept +{ + JLM_ASSERT(CurrentSequentialization_ <= Sequentializations_.size()); + return CurrentSequentialization_ != Sequentializations_.size(); +} + +void +ExhaustiveRegionSequentializer::ComputeSequentializations( + const rvsdg::Region & region, + util::HashSet & visited, + std::vector & sequentializedNodes) noexcept +{ + for (auto & node : region.Nodes()) + { + if (AllPredecessorsVisited(node, visited) && !visited.Contains(&node)) + { + sequentializedNodes.push_back(&node); + visited.Insert(&node); + + ComputeSequentializations(region, visited, sequentializedNodes); + + visited.Remove(&node); + sequentializedNodes.pop_back(); + } + } + + if (sequentializedNodes.size() == region.nnodes()) + { + Sequentializations_.emplace_back(sequentializedNodes); + } +} + +bool +ExhaustiveRegionSequentializer::AllPredecessorsVisited( + const rvsdg::Node & node, + const util::HashSet & visited) +{ + for (size_t n = 0; n < node.ninputs(); n++) + { + auto & origin = *node.input(n)->origin(); + if (const auto predecessor = rvsdg::TryGetOwnerNode(origin)) + { + if (!visited.Contains(predecessor)) + { + return false; + } + } + } + + return true; +} + +IdempotentRegionSequentializer::~IdempotentRegionSequentializer() noexcept = default; + +IdempotentRegionSequentializer::IdempotentRegionSequentializer(rvsdg::Region & region) + : RegionSequentializer(region) +{} + +void +IdempotentRegionSequentializer::ComputeNextSequentialization() +{} + +Sequentialization +IdempotentRegionSequentializer::GetSequentialization() +{ + auto sequentialization = Sequentialization(); + for (const auto node : rvsdg::TopDownTraverser(&GetRegion())) + { + sequentialization.push_back(node); + } + return sequentialization; +} + +bool +IdempotentRegionSequentializer::HasMoreSequentializations() const noexcept +{ + return true; +} + +RegionTreeSequentializer::~RegionTreeSequentializer() noexcept = default; + +RegionTreeSequentializer::RegionTreeSequentializer(SequentializerMap sequentializerMap) + : Sequentializers_(std::move(sequentializerMap)) +{} + +void +RegionTreeSequentializer::ComputeNextSequentializations() +{ + for (auto & [region, sequentializer] : Sequentializers_) + { + sequentializer->ComputeNextSequentialization(); + } +} + +bool +RegionTreeSequentializer::HasMoreSequentializations() const noexcept +{ + for (auto & [_, sequentializer] : Sequentializers_) + { + if (sequentializer->HasMoreSequentializations()) + return true; + } + + return false; +} + +Sequentialization +RegionTreeSequentializer::GetSequentialization(rvsdg::Region & region) +{ + JLM_ASSERT(Sequentializers_.find(®ion) != Sequentializers_.end()); + return Sequentializers_[®ion]->GetSequentialization(); +} + +template +void +InitializeUniformRegionTreeSequentializer( + rvsdg::Region & region, + SequentializerMap & sequentializerMap) +{ + auto sequentializer = std::make_unique(region); + + for (auto & node : region.Nodes()) + { + if (const auto structuralNode = dynamic_cast(&node)) + { + for (size_t n = 0; n < structuralNode->nsubregions(); n++) + { + const auto subregion = structuralNode->subregion(n); + InitializeUniformRegionTreeSequentializer( + *subregion, + sequentializerMap); + } + } + } + + sequentializerMap[®ion] = std::move(sequentializer); +} + +RegionTreeSequentializer +CreateIdempotentRegionTreeSequentializer(rvsdg::Region & rootRegion) +{ + SequentializerMap sequentializerMap; + InitializeUniformRegionTreeSequentializer( + rootRegion, + sequentializerMap); + return RegionTreeSequentializer(std::move(sequentializerMap)); +} + +RegionTreeSequentializer +CreateExhaustiveRegionTreeSequentializer(rvsdg::Region & rootRegion) +{ + SequentializerMap sequentializerMap; + InitializeUniformRegionTreeSequentializer( + rootRegion, + sequentializerMap); + return RegionTreeSequentializer(std::move(sequentializerMap)); +} + +} diff --git a/jlm/llvm/backend/RegionSequentializer.hpp b/jlm/llvm/backend/RegionSequentializer.hpp new file mode 100644 index 000000000..4b717cb4e --- /dev/null +++ b/jlm/llvm/backend/RegionSequentializer.hpp @@ -0,0 +1,220 @@ +/* + * Copyright 2025 Nico Reißmann + * See COPYING for terms of redistribution. + */ + +#ifndef JLM_LLVM_BACKEND_REGIONSEQUENTIALIZER_HPP +#define JLM_LLVM_BACKEND_REGIONSEQUENTIALIZER_HPP + +#include +#include +#include +#include + +namespace jlm::rvsdg +{ +class Node; +class Region; +} + +namespace jlm::llvm +{ + +using Sequentialization = std::vector; + +/** + * The RegionSequentializer class computes sequentializations, i.e., topological orderings, for a + * single region. The interface permits the computation of different sequentializations + * by invoking ComputeNextSequentialization(). It can be checked whether there are still orderings + * available by invoking HasMoreSequentializations(). + * + * Thus, all sequentializations can be obtained as follows: + * + * \code{.c} + * while(sequentializer.HasMoreSequentializations) + * { + * auto sequentialization = sequentializer.GetSequentialization(); + * ... + * sequentializer.ComputeNextSequentialization(); + * } + * \endcode + */ +class RegionSequentializer +{ +public: + virtual ~RegionSequentializer() noexcept; + + explicit RegionSequentializer(rvsdg::Region & region); + + RegionSequentializer(const RegionSequentializer &) = delete; + + RegionSequentializer(RegionSequentializer &&) = delete; + + RegionSequentializer & + operator=(const RegionSequentializer &) = delete; + + RegionSequentializer & + operator=(RegionSequentializer &&) = delete; + + /** + * @return The current sequentialization of the region. Nodes are stored in dependency-order in + * the sequentialization, i.e., nodes without any dependency appear first in the + * sequentialization. + */ + virtual Sequentialization + GetSequentialization() = 0; + + /** + * @return True, if there are more sequentializations to return, otherwise false. + */ + virtual bool + HasMoreSequentializations() const noexcept = 0; + + /** + * Computes the next sequentialization of the region. + */ + virtual void + ComputeNextSequentialization() = 0; + + /** + * @return The region for which sequentializations are computed. + */ + rvsdg::Region & + GetRegion() const noexcept + { + return *Region_; + } + +private: + rvsdg::Region * Region_; +}; + +/** + * The ExhaustiveRegionSequentializer class computes all sequentializations of a region. The + * sequentializer will wrap around after the "last" sequentialization and return the "first" + * sequentialization again. + */ +class ExhaustiveRegionSequentializer final : public RegionSequentializer +{ +public: + ~ExhaustiveRegionSequentializer() noexcept override = default; + + explicit ExhaustiveRegionSequentializer(rvsdg::Region & region); + + void + ComputeNextSequentialization() override; + + Sequentialization + GetSequentialization() override; + + bool + HasMoreSequentializations() const noexcept override; + +private: + void + ComputeSequentializations( + const rvsdg::Region & region, + util::HashSet & visited, + std::vector & sequentializedNodes) noexcept; + + static bool + AllPredecessorsVisited( + const rvsdg::Node & node, + const util::HashSet & visited); + + size_t CurrentSequentialization_ = 0; + std::vector Sequentializations_; +}; + +/** + * The IdempotentRegionSequentializer class computes a single sequentialization of a region + * and only ever returns this single sequentialization. + */ +class IdempotentRegionSequentializer final : public RegionSequentializer +{ +public: + ~IdempotentRegionSequentializer() noexcept override; + + explicit IdempotentRegionSequentializer(rvsdg::Region & region); + + Sequentialization + GetSequentialization() override; + + bool + HasMoreSequentializations() const noexcept override; + + void + ComputeNextSequentialization() override; +}; + +using SequentializerMap = + std::unordered_map>; + +/** + * The RegionTreeSequentializer class extends the concepts of the RegionSequentializer from a single + * region to a region tree. Thus, it computes the sequentializations for a root region and all its + * subregions. + */ +class RegionTreeSequentializer final +{ +public: + ~RegionTreeSequentializer() noexcept; + + explicit RegionTreeSequentializer(SequentializerMap sequentializerMap); + + RegionTreeSequentializer(const RegionTreeSequentializer &) = delete; + + RegionTreeSequentializer(RegionTreeSequentializer &&) = delete; + + RegionTreeSequentializer & + operator=(const RegionTreeSequentializer &) = delete; + + RegionTreeSequentializer & + operator=(RegionTreeSequentializer &&) = delete; + + /** + * Computes the next sequentialization for the regions in the tree. + */ + void + ComputeNextSequentializations(); + + /** + * @param region A (sub-)region of the region tree. + * @return The current sequentialization of the region. + */ + Sequentialization + GetSequentialization(rvsdg::Region & region); + + /** + * @return True, if there are more sequentializations to return, otherwise false. + */ + bool + HasMoreSequentializations() const noexcept; + +private: + SequentializerMap Sequentializers_; +}; + +/** + * Creates an instance of RegionTreeSequentializer where IdempotentRegionSequentializer instances + * are used for all regions in the tree. + * + * @param rootRegion The root of the region tree. + * @return An instance of RegionTreeSequentializer. + */ +RegionTreeSequentializer +CreateIdempotentRegionTreeSequentializer(rvsdg::Region & rootRegion); + +/** + * Creates an instance of RegionTreeSequentializer where IdempotentRegionSequentializer instances + * are used for all regions in the tree. + * + * @param rootRegion The root of the region tree. + * @return An instance of RegionTreeSequentializer. + */ +RegionTreeSequentializer +CreateExhaustiveRegionTreeSequentializer(rvsdg::Region & rootRegion); + +} + +#endif // JLM_LLVM_BACKEND_REGIONSEQUENTIALIZER_HPP diff --git a/jlm/llvm/backend/RvsdgToIpGraphConverter.cpp b/jlm/llvm/backend/RvsdgToIpGraphConverter.cpp index e0639d974..1ff8540f1 100644 --- a/jlm/llvm/backend/RvsdgToIpGraphConverter.cpp +++ b/jlm/llvm/backend/RvsdgToIpGraphConverter.cpp @@ -129,7 +129,9 @@ class RvsdgToIpGraphConverter::Statistics final : public util::Statistics RvsdgToIpGraphConverter::~RvsdgToIpGraphConverter() = default; -RvsdgToIpGraphConverter::RvsdgToIpGraphConverter() = default; +RvsdgToIpGraphConverter::RvsdgToIpGraphConverter(RegionTreeSequentializer & regionSequentializer) + : RegionTreeSequentializer_(®ionSequentializer) +{} std::unique_ptr RvsdgToIpGraphConverter::CreateInitialization(const delta::node & deltaNode) @@ -176,8 +178,9 @@ RvsdgToIpGraphConverter::ConvertRegion(rvsdg::Region & region) Context_->GetLastProcessedBasicBlock()->add_outedge(entryBlock); Context_->SetLastProcessedBasicBlock(entryBlock); - for (const auto & node : rvsdg::TopDownTraverser(®ion)) - ConvertNode(*node); + const auto sequentialization = RegionTreeSequentializer_->GetSequentialization(region); + for (const auto & node : sequentialization) + ConvertIntraProceduralNode(*node); const auto exitBlock = basic_block::create(*Context_->GetControlFlowGraph()); Context_->GetLastProcessedBasicBlock()->add_outedge(exitBlock); @@ -604,20 +607,12 @@ RvsdgToIpGraphConverter::ConvertDeltaNode(const delta::node & deltaNode) } void -RvsdgToIpGraphConverter::ConvertNode(const rvsdg::Node & node) +RvsdgToIpGraphConverter::ConvertInterProceduralNode(const rvsdg::Node & node) { if (const auto lambdaNode = dynamic_cast(&node)) { ConvertLambdaNode(*lambdaNode); } - else if (const auto gammaNode = dynamic_cast(&node)) - { - ConvertGammaNode(*gammaNode); - } - else if (const auto thetaNode = dynamic_cast(&node)) - { - ConvertThetaNode(*thetaNode); - } else if (const auto phiNode = dynamic_cast(&node)) { ConvertPhiNode(*phiNode); @@ -626,6 +621,24 @@ RvsdgToIpGraphConverter::ConvertNode(const rvsdg::Node & node) { ConvertDeltaNode(*deltaNode); } + else + { + JLM_UNREACHABLE( + util::strfmt("Unhandled node type: ", node.GetOperation().debug_string()).c_str()); + } +} + +void +RvsdgToIpGraphConverter::ConvertIntraProceduralNode(const rvsdg::Node & node) +{ + if (const auto gammaNode = dynamic_cast(&node)) + { + ConvertGammaNode(*gammaNode); + } + else if (const auto thetaNode = dynamic_cast(&node)) + { + ConvertThetaNode(*thetaNode); + } else if (const auto simpleNode = dynamic_cast(&node)) { ConvertSimpleNode(*simpleNode); @@ -638,11 +651,11 @@ RvsdgToIpGraphConverter::ConvertNode(const rvsdg::Node & node) } void -RvsdgToIpGraphConverter::ConvertNodes(const rvsdg::Graph & graph) +RvsdgToIpGraphConverter::ConvertInterProceduralNodes(const rvsdg::Graph & graph) { for (const auto & node : rvsdg::TopDownTraverser(&graph.GetRootRegion())) { - ConvertNode(*node); + ConvertInterProceduralNode(*node); } } @@ -694,7 +707,7 @@ RvsdgToIpGraphConverter::ConvertModule( Context_ = Context::Create(*ipGraphModule); ConvertImports(rvsdgModule.Rvsdg()); - ConvertNodes(rvsdgModule.Rvsdg()); + ConvertInterProceduralNodes(rvsdgModule.Rvsdg()); statistics->End(*ipGraphModule); statisticsCollector.CollectDemandedStatistics(std::move(statistics)); @@ -705,9 +718,10 @@ RvsdgToIpGraphConverter::ConvertModule( std::unique_ptr RvsdgToIpGraphConverter::CreateAndConvertModule( RvsdgModule & rvsdgModule, - util::StatisticsCollector & statisticsCollector) + util::StatisticsCollector & statisticsCollector, + RegionTreeSequentializer & regionSequentializer) { - RvsdgToIpGraphConverter converter; + RvsdgToIpGraphConverter converter(regionSequentializer); return converter.ConvertModule(rvsdgModule, statisticsCollector); } diff --git a/jlm/llvm/backend/RvsdgToIpGraphConverter.hpp b/jlm/llvm/backend/RvsdgToIpGraphConverter.hpp index cec58eae8..919281ea2 100644 --- a/jlm/llvm/backend/RvsdgToIpGraphConverter.hpp +++ b/jlm/llvm/backend/RvsdgToIpGraphConverter.hpp @@ -6,6 +6,7 @@ #ifndef JLM_LLVM_BACKEND_RVSDGTOIPGRAPHCONVERTER_HPP #define JLM_LLVM_BACKEND_RVSDGTOIPGRAPHCONVERTER_HPP +#include #include #include @@ -52,7 +53,7 @@ class RvsdgToIpGraphConverter final public: ~RvsdgToIpGraphConverter(); - RvsdgToIpGraphConverter(); + explicit RvsdgToIpGraphConverter(RegionTreeSequentializer & regionSequentializer); RvsdgToIpGraphConverter(const RvsdgToIpGraphConverter &) = delete; @@ -70,17 +71,21 @@ class RvsdgToIpGraphConverter final static std::unique_ptr CreateAndConvertModule( RvsdgModule & rvsdgModule, - util::StatisticsCollector & statisticsCollector); + util::StatisticsCollector & statisticsCollector, + RegionTreeSequentializer & regionSequentializer); private: void ConvertImports(const rvsdg::Graph & graph); void - ConvertNodes(const rvsdg::Graph & graph); + ConvertInterProceduralNodes(const rvsdg::Graph & graph); void - ConvertNode(const rvsdg::Node & node); + ConvertInterProceduralNode(const rvsdg::Node & node); + + void + ConvertIntraProceduralNode(const rvsdg::Node & node); void ConvertDeltaNode(const delta::node & deltaNode); @@ -116,6 +121,8 @@ class RvsdgToIpGraphConverter final RequiresSsaPhiOperation(const rvsdg::ThetaNode::LoopVar & loopVar, const variable & v); std::unique_ptr Context_; + + RegionTreeSequentializer * RegionTreeSequentializer_; }; } diff --git a/jlm/rvsdg/region.hpp b/jlm/rvsdg/region.hpp index e4c4d44b6..8f0292918 100644 --- a/jlm/rvsdg/region.hpp +++ b/jlm/rvsdg/region.hpp @@ -239,17 +239,17 @@ class Region using TopNodeRange = util::IteratorRange; using TopNodeConstRange = util::IteratorRange; - using NodeIterator = region_nodes_list::iterator; - using NodeConstIterator = region_nodes_list::const_iterator; - using NodeRange = util::IteratorRange; - using NodeConstRange = util::IteratorRange; - using BottomNodeIterator = region_bottom_node_list::iterator; using BottomNodeConstIterator = region_bottom_node_list::const_iterator; using BottomNodeRange = util::IteratorRange; using BottomNodeConstRange = util::IteratorRange; public: + using NodeIterator = region_nodes_list::iterator; + using NodeConstIterator = region_nodes_list::const_iterator; + using NodeRange = util::IteratorRange; + using NodeConstRange = util::IteratorRange; + ~Region() noexcept; Region(rvsdg::Region * parent, Graph * graph); diff --git a/jlm/tooling/Command.cpp b/jlm/tooling/Command.cpp index c53703243..5ccc8e785 100644 --- a/jlm/tooling/Command.cpp +++ b/jlm/tooling/Command.cpp @@ -529,8 +529,12 @@ JlmOptCommand::PrintAsLlvm( const util::filepath & outputFile, util::StatisticsCollector & statisticsCollector) { - auto jlm_module = - llvm::RvsdgToIpGraphConverter::CreateAndConvertModule(rvsdgModule, statisticsCollector); + auto sequentializer = + llvm::CreateIdempotentRegionTreeSequentializer(rvsdgModule.Rvsdg().GetRootRegion()); + auto jlm_module = llvm::RvsdgToIpGraphConverter::CreateAndConvertModule( + rvsdgModule, + statisticsCollector, + sequentializer); ::llvm::LLVMContext ctx; auto llvm_module = llvm::IpGraphToLlvmConverter::CreateAndConvertModule(*jlm_module, ctx); diff --git a/tests/TestRvsdgs.hpp b/tests/TestRvsdgs.hpp index 5cd6a9583..c3a023305 100644 --- a/tests/TestRvsdgs.hpp +++ b/tests/TestRvsdgs.hpp @@ -76,6 +76,13 @@ class RvsdgTest */ class StoreTest1 final : public RvsdgTest { +public: + rvsdg::LambdaNode & + GetLambdaNode() const noexcept + { + return *lambda; + } + private: std::unique_ptr SetupRvsdg() override; @@ -148,6 +155,13 @@ class StoreTest2 final : public RvsdgTest */ class LoadTest1 final : public RvsdgTest { +public: + const rvsdg::LambdaNode & + GetLambdaNode() const noexcept + { + return *lambda; + } + private: std::unique_ptr SetupRvsdg() override; diff --git a/tests/jlm/llvm/backend/ExhaustiveSequentializerTests.cpp b/tests/jlm/llvm/backend/ExhaustiveSequentializerTests.cpp new file mode 100644 index 000000000..679cb2a10 --- /dev/null +++ b/tests/jlm/llvm/backend/ExhaustiveSequentializerTests.cpp @@ -0,0 +1,36 @@ +/* + * Copyright 2025 Nico Reißmann + * See COPYING for terms of redistribution. + */ + +#include +#include +#include + +static int +Test() +{ + jlm::tests::LoadTest1 test; + test.InitializeTest(); + + auto & lambdaRegion = *test.GetLambdaNode().subregion(); + auto sequentializer = + jlm::llvm::CreateExhaustiveRegionTreeSequentializer(*test.GetLambdaNode().subregion()); + assert(sequentializer.HasMoreSequentializations()); + + while (sequentializer.HasMoreSequentializations()) + { + auto sequentialization = sequentializer.GetSequentialization(lambdaRegion); + for (const auto & node : sequentialization) + { + std::cout << node->GetOperation().debug_string() << std::endl; + } + std::cout << std::endl; + + sequentializer.ComputeNextSequentializations(); + } + + return 0; +} + +JLM_UNIT_TEST_REGISTER("jlm/llvm/backend/ExhaustiveSequentializerTests-Test", Test) diff --git a/tests/jlm/llvm/backend/RvsdgToIpGraphConverterTests.cpp b/tests/jlm/llvm/backend/RvsdgToIpGraphConverterTests.cpp index bb2abe433..a85e153f2 100644 --- a/tests/jlm/llvm/backend/RvsdgToIpGraphConverterTests.cpp +++ b/tests/jlm/llvm/backend/RvsdgToIpGraphConverterTests.cpp @@ -49,7 +49,12 @@ GammaWithMatch() // Act StatisticsCollector statisticsCollector; - auto module = RvsdgToIpGraphConverter::CreateAndConvertModule(rvsdgModule, statisticsCollector); + auto sequentializer = + CreateIdempotentRegionTreeSequentializer(rvsdgModule.Rvsdg().GetRootRegion()); + auto module = RvsdgToIpGraphConverter::CreateAndConvertModule( + rvsdgModule, + statisticsCollector, + sequentializer); print(*module, stdout); // Assert @@ -101,7 +106,12 @@ GammaWithoutMatch() // Act StatisticsCollector statisticsCollector; - auto module = RvsdgToIpGraphConverter::CreateAndConvertModule(rvsdgModule, statisticsCollector); + auto sequentializer = + CreateIdempotentRegionTreeSequentializer(rvsdgModule.Rvsdg().GetRootRegion()); + auto module = RvsdgToIpGraphConverter::CreateAndConvertModule( + rvsdgModule, + statisticsCollector, + sequentializer); print(*module, stdout); // Assert @@ -158,7 +168,12 @@ EmptyGammaWithThreeSubregions() // Act StatisticsCollector statisticsCollector; - auto module = RvsdgToIpGraphConverter::CreateAndConvertModule(rvsdgModule, statisticsCollector); + auto sequentializer = + CreateIdempotentRegionTreeSequentializer(rvsdgModule.Rvsdg().GetRootRegion()); + auto module = RvsdgToIpGraphConverter::CreateAndConvertModule( + rvsdgModule, + statisticsCollector, + sequentializer); print(*module, stdout); // Assert @@ -211,7 +226,12 @@ PartialEmptyGamma() // Act StatisticsCollector statisticsCollector; - auto module = RvsdgToIpGraphConverter::CreateAndConvertModule(rvsdgModule, statisticsCollector); + auto sequentializer = + CreateIdempotentRegionTreeSequentializer(rvsdgModule.Rvsdg().GetRootRegion()); + auto module = RvsdgToIpGraphConverter::CreateAndConvertModule( + rvsdgModule, + statisticsCollector, + sequentializer); // Assert auto & ipg = module->ipgraph(); @@ -279,7 +299,9 @@ RecursiveData() // Act jlm::util::StatisticsCollector statisticsCollector; - auto module = RvsdgToIpGraphConverter::CreateAndConvertModule(rm, statisticsCollector); + auto sequentializer = CreateIdempotentRegionTreeSequentializer(rm.Rvsdg().GetRootRegion()); + auto module = + RvsdgToIpGraphConverter::CreateAndConvertModule(rm, statisticsCollector, sequentializer); print(*module, stdout); // Assert diff --git a/tools/jlm-hls/jlm-hls.cpp b/tools/jlm-hls/jlm-hls.cpp index 4928db4fe..5f5a96da9 100644 --- a/tools/jlm-hls/jlm-hls.cpp +++ b/tools/jlm-hls/jlm-hls.cpp @@ -35,7 +35,12 @@ llvmToFile(jlm::llvm::RvsdgModule & module, const jlm::util::filepath & fileName { llvm::LLVMContext ctx; jlm::util::StatisticsCollector statisticsCollector; - auto jm = jlm::llvm::RvsdgToIpGraphConverter::CreateAndConvertModule(module, statisticsCollector); + auto sequentializer = + jlm::llvm::CreateIdempotentRegionTreeSequentializer(module.Rvsdg().GetRootRegion()); + auto jm = jlm::llvm::RvsdgToIpGraphConverter::CreateAndConvertModule( + module, + statisticsCollector, + sequentializer); auto lm = jlm::llvm::IpGraphToLlvmConverter::CreateAndConvertModule(*jm, ctx); std::error_code EC; llvm::raw_fd_ostream os(fileName.to_str(), EC);