[Mesa-dev] [PATCH] nv50/ir: make sure cfg iterator always hits all blocks

Ilia Mirkin imirkin at alum.mit.edu
Fri Aug 19 04:45:02 UTC 2016


In some very specially-crafted cases, we could attempt to visit a node
that has already been visited, and then run out of bb's to visit, while
there were still cross blocks on the list. Make sure that those get
moved over in that case.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96274
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
Cc: mesa-stable at lists.freedesktop.org
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_graph.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.cpp
index 23414d5..b1076cf 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.cpp
@@ -280,21 +280,24 @@ public:
    virtual void next() { if (pos < count) ++pos; }
    virtual void reset() { pos = 0; }
 
 private:
    void search(Graph::Node *node, const int sequence)
    {
       Stack bb, cross;
 
       bb.push(node);
 
-      while (bb.getSize()) {
+      while (bb.getSize() || cross.getSize()) {
+         if (bb.getSize() == 0)
+            cross.moveTo(bb);
+
          node = reinterpret_cast<Graph::Node *>(bb.pop().u.p);
          assert(node);
          if (!node->visit(sequence))
             continue;
          node->tag = 0;
 
          for (Graph::EdgeIterator ei = node->outgoing(); !ei.end(); ei.next()) {
             switch (ei.getType()) {
             case Graph::Edge::TREE:
             case Graph::Edge::FORWARD:
@@ -307,23 +310,20 @@ private:
             case Graph::Edge::CROSS:
                if (++(ei.getNode()->tag) == 1)
                   cross.push(ei.getNode());
                break;
             default:
                assert(!"unknown edge kind in CFG");
                break;
             }
          }
          nodes[count++] = node;
-
-         if (bb.getSize() == 0)
-            cross.moveTo(bb);
       }
    }
 
 private:
    Graph::Node **nodes;
    int count;
    int pos;
 };
 
 IteratorRef Graph::iteratorCFG()
-- 
2.7.3



More information about the mesa-dev mailing list