[llvm-commits] CVS: llvm/lib/Analysis/BasicAliasAnalysis.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Jan 30 16:18:03 PST 2004
Changes in directory llvm/lib/Analysis:
BasicAliasAnalysis.cpp updated: 1.26 -> 1.27
---
Log message:
Implement the pointsToConstantMemory() method.
---
Diffs of the changes: (+14 -3)
Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.26 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.27
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.26 Mon Jan 12 11:57:32 2004
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp Fri Jan 30 16:17:24 2004
@@ -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 @@
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 @@
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.
More information about the llvm-commits
mailing list