[all-commits] [llvm/llvm-project] d91f86: [ADT] Update RPOT to work with specializations of ...

Florian Hahn via All-commits all-commits at lists.llvm.org
Sat Apr 17 12:49:06 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d91f864ced6eebe8db35c092c8da29e87cd882b2
      https://github.com/llvm/llvm-project/commit/d91f864ced6eebe8db35c092c8da29e87cd882b2
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2021-04-17 (Sat, 17 Apr 2021)

  Changed paths:
    M llvm/include/llvm/ADT/PostOrderIterator.h
    M llvm/unittests/ADT/PostOrderIteratorTest.cpp

  Log Message:
  -----------
  [ADT] Update RPOT to work with specializations of different types.

At the moment, ReversePostOrderTraversal performs a post-order walk on
the entry node of the passed in graph, rather than the graph type
itself.

If GT::NodeRef is the same as GraphT, everything works as expected and
this is the case for the current uses in-tree. But it does not work as
expected if GraphT != GT::NodeRef. In that case, we either fail to build
(if there is no GraphTrait specialization for GT:NodeRef) or we pick the
GraphTrait specialization for GT::NodeRef, instead of the specialization
of GraphT.

Both the depth-first and post-order iterators pick the expected
specalization and this patch updates ReversePostOrderTraversal to
delegate to po_begin & po_end to pick the right specialization, rather
than forcing using GraphTraits<GT::NodeRef>, by first getting the entry
node.

This makes `ReversePostOrderTraversal<Graph<6>> RPOT(G);` build and
work as expected in the test.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D100169




More information about the All-commits mailing list