aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/AliasAnalysis.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-06-24 11:58:16 +0200
committerNikita Popov <npopov@redhat.com>2022-06-24 11:59:15 +0200
commit54eff7da3c6147451b0fd4defb1421db167dc9c6 (patch)
tree58fc562f2705e7bbf73ae316aeb150985b1e3588 /llvm/lib/Analysis/AliasAnalysis.cpp
parenta129a371610dc342402dcdd122330369b25ff247 (diff)
downloadllvm-54eff7da3c6147451b0fd4defb1421db167dc9c6.zip
llvm-54eff7da3c6147451b0fd4defb1421db167dc9c6.tar.gz
llvm-54eff7da3c6147451b0fd4defb1421db167dc9c6.tar.bz2
[AA] Export isEscapeSource() API (NFC)
Export API that was previously private to BasicAliasAnalysis and will be used in D127202.
Diffstat (limited to 'llvm/lib/Analysis/AliasAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/AliasAnalysis.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index 7a8cccc..e249c38 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -987,6 +987,28 @@ bool llvm::isIdentifiedFunctionLocal(const Value *V) {
return isa<AllocaInst>(V) || isNoAliasCall(V) || isNoAliasOrByValArgument(V);
}
+bool llvm::isEscapeSource(const Value *V) {
+ if (auto *CB = dyn_cast<CallBase>(V))
+ return !isIntrinsicReturningPointerAliasingArgumentWithoutCapturing(CB,
+ true);
+
+ // The load case works because isNonEscapingLocalObject considers all
+ // stores to be escapes (it passes true for the StoreCaptures argument
+ // to PointerMayBeCaptured).
+ if (isa<LoadInst>(V))
+ return true;
+
+ // The inttoptr case works because isNonEscapingLocalObject considers all
+ // means of converting or equating a pointer to an int (ptrtoint, ptr store
+ // which could be followed by an integer load, ptr<->int compare) as
+ // escaping, and objects located at well-known addresses via platform-specific
+ // means cannot be considered non-escaping local objects.
+ if (isa<IntToPtrInst>(V))
+ return true;
+
+ return false;
+}
+
bool llvm::isNotVisibleOnUnwind(const Value *Object,
bool &RequiresNoCaptureBeforeUnwind) {
RequiresNoCaptureBeforeUnwind = false;