diff options
| author | Chris Lattner <sabre@nondot.org> | 2004-01-30 22:17:24 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2004-01-30 22:17:24 +0000 |
| commit | f0eac5d0d376b7b988aa8fb08a1539b155d6dee2 (patch) | |
| tree | 71cc57e3a86d82f33812925cb453fbf42c58f197 /llvm/lib/Analysis | |
| parent | 9605576a21ecfad8044f8e4b4886fead9180cafd (diff) | |
| download | bcm5719-llvm-f0eac5d0d376b7b988aa8fb08a1539b155d6dee2.tar.gz bcm5719-llvm-f0eac5d0d376b7b988aa8fb08a1539b155d6dee2.zip | |
Implement the pointsToConstantMemory() method.
llvm-svn: 11022
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/BasicAliasAnalysis.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index ce8379ddc7d..dd66eb59b03 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -23,7 +23,7 @@ #include "llvm/Argument.h" #include "llvm/iOther.h" #include "llvm/Constants.h" -#include "llvm/GlobalValue.h" +#include "llvm/GlobalVariable.h" #include "llvm/DerivedTypes.h" #include "llvm/Target/TargetData.h" #include "llvm/Support/GetElementPtrTypeIterator.h" @@ -41,10 +41,13 @@ namespace { virtual void initializePass(); - // alias - This is the only method here that does anything interesting... - // AliasResult alias(const Value *V1, unsigned V1Size, const Value *V2, unsigned V2Size); + + /// pointsToConstantMemory - Chase pointers until we find a (constant + /// global) or not. + bool pointsToConstantMemory(const Value *P); + private: // CheckGEPInstructions - Check two GEP instructions with known // must-aliasing base pointers. This checks to see if the index expressions @@ -124,6 +127,14 @@ static const Value *GetGEPOperands(const Value *V, std::vector<Value*> &GEPOps){ return V; } +/// pointsToConstantMemory - Chase pointers until we find a (constant +/// global) or not. +bool BasicAliasAnalysis::pointsToConstantMemory(const Value *P) { + const Value *V = getUnderlyingObject(P); + if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) + return GV->isConstant(); + return false; +} // alias - Provide a bunch of ad-hoc rules to disambiguate in common cases, such // as array references. Note that this function is heavily tail recursive. |

