diff options
author | Dan Gohman <gohman@apple.com> | 2009-02-03 01:28:32 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-02-03 01:28:32 +0000 |
commit | a5f81bba4ab18d6129774d4d67495f14b6f64375 (patch) | |
tree | d8bfcb33862ac7c1e125653bebc3eadaffc306fa /lib/Analysis/AliasAnalysis.cpp | |
parent | d91a61ae3d115e4a2e0f719af40ff842af13bb43 (diff) |
Move isIdentifiedObject and isNoAliasCall into AliasAnalysis.cpp since
they are useful to analyses other than BasicAliasAnalysis.cpp. Include
the full comment for isIdentifiedObject in the header file. Thanks to
Chris for suggeseting this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63589 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/AliasAnalysis.cpp')
-rw-r--r-- | lib/Analysis/AliasAnalysis.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Analysis/AliasAnalysis.cpp b/lib/Analysis/AliasAnalysis.cpp index c8c43a69ef..d5de2fe616 100644 --- a/lib/Analysis/AliasAnalysis.cpp +++ b/lib/Analysis/AliasAnalysis.cpp @@ -207,6 +207,30 @@ bool AliasAnalysis::canInstructionRangeModify(const Instruction &I1, return false; } +/// isNoAliasCall - Return true if this pointer is returned by a noalias +/// function. +bool llvm::isNoAliasCall(const Value *V) { + if (isa<CallInst>(V) || isa<InvokeInst>(V)) + return CallSite(const_cast<Instruction*>(cast<Instruction>(V))) + .paramHasAttr(0, Attribute::NoAlias); + return false; +} + +/// isIdentifiedObject - Return true if this pointer refers to a distinct and +/// identifiable object. This returns true for: +/// Global Variables and Functions +/// Allocas and Mallocs +/// ByVal and NoAlias Arguments +/// NoAlias returns +/// +bool llvm::isIdentifiedObject(const Value *V) { + if (isa<GlobalValue>(V) || isa<AllocationInst>(V) || isNoAliasCall(V)) + return true; + if (const Argument *A = dyn_cast<Argument>(V)) + return A->hasNoAliasAttr() || A->hasByValAttr(); + return false; +} + // Because of the way .a files work, we must force the BasicAA implementation to // be pulled in if the AliasAnalysis classes are pulled in. Otherwise we run // the risk of AliasAnalysis being used, but the default implementation not |