Skip to content

Commit

Permalink
[FunctionAttrs] Remove dead code code in nocaptures inference (NFCI)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikic committed Jan 30, 2025
1 parent 9acaaeb commit a3fdc36
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions llvm/lib/Transforms/IPO/FunctionAttrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1296,23 +1296,14 @@ 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.
for (ArgumentGraphNode *I : ArgumentSCC) {
ArgumentSCCNodes.insert(I->Definition);
}

bool SCCCaptured = false;
for (ArgumentGraphNode *N : ArgumentSCC) {
for (ArgumentGraphNode *Use : N->Uses) {
Argument *A = Use->Definition;
Expand Down

0 comments on commit a3fdc36

Please sign in to comment.