[llvm] a049ce9 - [RDF] Stop looking when reached code node in getNextRef with NextOnly

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 9 15:30:21 PDT 2023


Author: Krzysztof Parzyszek
Date: 2023-06-09T15:21:01-07:00
New Revision: a049ce9d1bd5a7c1c4fcccc6a801b72b00ea8e0f

URL: https://github.com/llvm/llvm-project/commit/a049ce9d1bd5a7c1c4fcccc6a801b72b00ea8e0f
DIFF: https://github.com/llvm/llvm-project/commit/a049ce9d1bd5a7c1c4fcccc6a801b72b00ea8e0f.diff

LOG: [RDF] Stop looking when reached code node in getNextRef with NextOnly

NextOnly tells getNextRef to only check the next node in the chain, and
stop iterating. The loop didn't stop though when the next link pointed
back to the beginning of the circular list.

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/RDFGraph.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/RDFGraph.h b/llvm/include/llvm/CodeGen/RDFGraph.h
index f3fe6ad81dd57..1c7108fe8dc53 100644
--- a/llvm/include/llvm/CodeGen/RDFGraph.h
+++ b/llvm/include/llvm/CodeGen/RDFGraph.h
@@ -926,6 +926,14 @@ auto RefNode::getNextRef(RegisterRef RR, Predicate P, bool NextOnly,
     } else {
       // We've hit the beginning of the chain.
       assert(NA.Addr->getType() == NodeAttrs::Code);
+      // Make sure we stop here with NextOnly. Otherwise we can return the
+      // wrong ref. Consider the following while creating/linking shadow uses:
+      //   -> code -> sr1 -> sr2 -> [back to code]
+      // Say that shadow refs sr1, and sr2 have been linked, but we need to
+      // create and link another one. Starting from sr2, we'd hit the code
+      // node and return sr1 if the iteration didn't stop here.
+      if (NextOnly)
+        break;
       Code CA = NA;
       NA = CA.Addr->getFirstMember(G);
     }


        


More information about the llvm-commits mailing list