aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/BasicAliasAnalysis.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-01-30 22:17:24 +0000
committerChris Lattner <sabre@nondot.org>2004-01-30 22:17:24 +0000
commitbc1daaa8bb13f2cce6801f49928697fcde095a2e (patch)
tree2eec7ce9d60c1cd7fc0c570d8dcb86f8a0a6c885 /lib/Analysis/BasicAliasAnalysis.cpp
parentf4d904d7e326c9cbed497ca681b6270170fd2020 (diff)
Implement the pointsToConstantMemory() method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11022 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index ce8379ddc7..dd66eb59b0 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/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.