[CaptureTracking] Use isIdentifiedFunctionLocal() (NFC)
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 13 May 2021 21:03:46 +0000 (23:03 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 13 May 2021 21:06:42 +0000 (23:06 +0200)
These conditions together exactly match isIdentifiedFunctionLocal(),
and this is also what we logically want to check for here.

llvm/lib/Analysis/CaptureTracking.cpp

index cf5e53b..7c3b4c6 100644 (file)
@@ -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
@@ -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;
 }