[clang] [llvm] [CaptureTracking][FunctionAttrs] Add support for CaptureInfo (PR #125880)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 6 10:58:05 PST 2025
================
@@ -1303,27 +1341,42 @@ static void addArgumentAttrs(const SCCNodeSet &SCCNodes,
ArgumentSCCNodes.insert(I->Definition);
}
- bool SCCCaptured = false;
+ // At the SCC level, only track merged CaptureComponents. We're not
+ // currently prepared to handle propagation of return-only captures across
+ // the SCC.
+ CaptureComponents CC = CaptureComponents::None;
for (ArgumentGraphNode *N : ArgumentSCC) {
for (ArgumentGraphNode *Use : N->Uses) {
Argument *A = Use->Definition;
- if (A->hasNoCaptureAttr() || ArgumentSCCNodes.count(A))
- continue;
- SCCCaptured = true;
+ if (ArgumentSCCNodes.count(A))
+ CC |= Use->CC;
+ else
+ CC |= CaptureComponents(A->getAttributes().getCaptureInfo());
break;
}
- if (SCCCaptured)
+ if (capturesAll(CC))
break;
}
- if (SCCCaptured)
- continue;
- for (ArgumentGraphNode *N : ArgumentSCC) {
- Argument *A = N->Definition;
- A->addAttr(
- Attribute::getWithCaptureInfo(A->getContext(), CaptureInfo::none()));
- ++NumNoCapture;
- Changed.insert(A->getParent());
+ if (!capturesAll(CC)) {
+ for (ArgumentGraphNode *N : ArgumentSCC) {
+ Argument *A = N->Definition;
+ CaptureInfo CI = N->CC | CC;
+ A->addAttr(Attribute::getWithCaptureInfo(A->getContext(), CI));
+ addCapturesStat(CI);
+ Changed.insert(A->getParent());
+ }
+ }
+
+ // TODO(captures): Ignore address-only captures.
+ if (!capturesNothing(CC)) {
+ // As the pointer may be captured, determine the pointer attributes
+ // looking at each argument invidivually.
+ for (ArgumentGraphNode *N : ArgumentSCC) {
+ if (DetermineAccessAttrsForSingleton(N->Definition))
+ Changed.insert(N->Definition->getParent());
+ }
----------------
goldsteinn wrote:
What is this for?
https://github.com/llvm/llvm-project/pull/125880
More information about the cfe-commits
mailing list