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

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 12 10:46:22 PDT 2023


Author: Krzysztof Parzyszek
Date: 2023-06-12T10:46:01-07:00
New Revision: 85f1726c1b7dc53f3a71c74601614fa4a0bfa8cd

URL: https://github.com/llvm/llvm-project/commit/85f1726c1b7dc53f3a71c74601614fa4a0bfa8cd
DIFF: https://github.com/llvm/llvm-project/commit/85f1726c1b7dc53f3a71c74601614fa4a0bfa8cd.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.

Recommit this one right now, because it fixes a latent bug.

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 97673a249237c..ead048d090fae 100644
--- a/llvm/include/llvm/CodeGen/RDFGraph.h
+++ b/llvm/include/llvm/CodeGen/RDFGraph.h
@@ -892,6 +892,14 @@ NodeAddr<RefNode *> RefNode::getNextRef(RegisterRef RR, Predicate P,
     } 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;
       NodeAddr<CodeNode *> CA = NA;
       NA = CA.Addr->getFirstMember(G);
     }


        


More information about the llvm-commits mailing list