[llvm] a3fdc36 - [FunctionAttrs] Remove dead code code in nocaptures inference (NFCI)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 30 07:28:28 PST 2025


Author: Nikita Popov
Date: 2025-01-30T16:28:19+01:00
New Revision: a3fdc36ac97fc7ed5e1e78564db8f58a6fa1103d

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

LOG: [FunctionAttrs] Remove dead code code in nocaptures inference (NFCI)

An argument graph node without uses forms a trivial SCC, which will
already be handled by the preceding branch.

If a node in the SCC points to a node with empty uses, then it will
be part of a different SCC, and as such assumed to be capturing
if it does not have an attribute. There is no need to handle them
separately.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/FunctionAttrs.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index f2419e42862f3b..cf56f67e4de3f5 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -1296,16 +1296,6 @@ static void addArgumentAttrs(const SCCNodeSet &SCCNodes,
       continue;
     }
 
-    bool SCCCaptured = false;
-    for (ArgumentGraphNode *Node : ArgumentSCC) {
-      if (Node->Uses.empty() && !Node->Definition->hasNoCaptureAttr()) {
-        SCCCaptured = true;
-        break;
-      }
-    }
-    if (SCCCaptured)
-      continue;
-
     SmallPtrSet<Argument *, 8> ArgumentSCCNodes;
     // Fill ArgumentSCCNodes with the elements of the ArgumentSCC.  Used for
     // quickly looking up whether a given Argument is in this ArgumentSCC.
@@ -1313,6 +1303,7 @@ static void addArgumentAttrs(const SCCNodeSet &SCCNodes,
       ArgumentSCCNodes.insert(I->Definition);
     }
 
+    bool SCCCaptured = false;
     for (ArgumentGraphNode *N : ArgumentSCC) {
       for (ArgumentGraphNode *Use : N->Uses) {
         Argument *A = Use->Definition;


        


More information about the llvm-commits mailing list