Skip to content

Commit

Permalink
[CaptureTracking] Use isIdentifiedFunctionLocal() (NFC)
Browse files Browse the repository at this point in the history
These conditions together exactly match isIdentifiedFunctionLocal(),
and this is also what we logically want to check for here.
  • Loading branch information
nikic committed May 13, 2021
1 parent dce158c commit 425781b
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions llvm/lib/Analysis/CaptureTracking.cpp
Expand Up @@ -423,8 +423,8 @@ bool llvm::isNonEscapingLocalObject(
return CacheIt->second;
}

// If this is a local allocation, check to see if it escapes.
if (isa<AllocaInst>(V) || isNoAliasCall(V)) {
// If this is an identified function-local object, check to see if it escapes.
if (isIdentifiedFunctionLocal(V)) {
// Set StoreCaptures to True so that we can assume in our callers that the
// pointer is not the result of a load instruction. Currently
// PointerMayBeCaptured doesn't have any special analysis for the
Expand All @@ -436,19 +436,5 @@ bool llvm::isNonEscapingLocalObject(
return Ret;
}

// If this is an argument that corresponds to a byval or noalias argument,
// then it has not escaped before entering the function. Check if it escapes
// inside the function.
if (const Argument *A = dyn_cast<Argument>(V))
if (A->hasByValAttr() || A->hasNoAliasAttr()) {
// Note even if the argument is marked nocapture, we still need to check
// for copies made inside the function. The nocapture attribute only
// specifies that there are no copies made that outlive the function.
auto Ret = !PointerMayBeCaptured(V, false, /*StoreCaptures=*/true);
if (IsCapturedCache)
CacheIt->second = Ret;
return Ret;
}

return false;
}

0 comments on commit 425781b

Please sign in to comment.