summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2009-01-05 21:19:53 +0000
committerDuncan Sands <baldrick@free.fr>2009-01-05 21:19:53 +0000
commit8d65f3690e2aabc0e9978c14c62d4397a7801453 (patch)
tree396a99e2c3286fe9903d160dce2fdd9d5d1be936 /llvm/lib/Analysis/BasicAliasAnalysis.cpp
parent8804293fe977b262865caf28a70ed1fed1c93645 (diff)
downloadbcm5719-llvm-8d65f3690e2aabc0e9978c14c62d4397a7801453.tar.gz
bcm5719-llvm-8d65f3690e2aabc0e9978c14c62d4397a7801453.zip
When checking if an Argument escapes, check if
the argument is marked nocapture - no need to analyze the argument if the answer is already known! llvm-svn: 61753
Diffstat (limited to 'llvm/lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/BasicAliasAnalysis.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 57d320971db..9608a28edd8 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -35,10 +35,11 @@ using namespace llvm;
// Useful predicates
//===----------------------------------------------------------------------===//
-// Determine if an AllocationInst instruction escapes from the function it is
-// contained in. If it does not escape, there is no way for another function to
-// mod/ref it. We do this by looking at its uses and determining if the uses
-// can escape (recursively).
+// Determine if a value escapes from the function it is contained in (being
+// returned by the function does not count as escaping here). If a value local
+// to the function does not escape, there is no way another function can mod/ref
+// it. We do this by looking at its uses and determining if they can escape
+// (recursively).
static bool AddressMightEscape(const Value *V) {
for (Value::use_const_iterator UI = V->use_begin(), E = V->use_end();
UI != E; ++UI) {
@@ -161,12 +162,17 @@ static bool isNonEscapingLocalObject(const Value *V) {
// If this is a local allocation, check to see if it escapes.
if (isa<AllocationInst>(V) || isNoAliasCall(V))
return !AddressMightEscape(V);
-
+
// If this is an argument that corresponds to a byval or noalias argument,
- // it can't escape either.
+ // 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())
+ if (A->hasByValAttr() || A->hasNoAliasAttr()) {
+ // Don't bother analyzing arguments already known not to escape.
+ if (A->hasNoCaptureAttr())
+ return true;
return !AddressMightEscape(V);
+ }
return false;
}
OpenPOWER on IntegriCloud