Adjust to implement new AA interface

llvm-svn: 5638
This commit is contained in:
Chris Lattner 2003-02-26 19:29:36 +00:00
parent 13082d63dd
commit e79b8319a6
2 changed files with 17 additions and 31 deletions

View File

@ -24,11 +24,13 @@ namespace {
// program.
//
bool run(Module &M) {
InitializeAliasAnalysis(this);
TD = &getAnalysis<TDDataStructures>();
return false;
}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AliasAnalysis::getAnalysisUsage(AU);
AU.setPreservesAll(); // Does not transform code...
AU.addRequired<TDDataStructures>(); // Uses TD Datastructures
AU.addRequired<AliasAnalysis>(); // Chains to another AA impl...
@ -39,19 +41,8 @@ namespace {
//
// alias - This is the only method here that does anything interesting...
Result alias(const Value *V1, const Value *V2);
/// canCallModify - Not implemented yet: FIXME
///
Result canCallModify(const CallInst &CI, const Value *Ptr) {
return MayAlias;
}
/// canInvokeModify - Not implemented yet: FIXME
///
Result canInvokeModify(const InvokeInst &I, const Value *Ptr) {
return MayAlias;
}
AliasResult alias(const Value *V1, unsigned V1Size,
const Value *V2, unsigned V2Size);
};
// Register the pass...
@ -75,7 +66,9 @@ static const Function *getValueFunction(const Value *V) {
}
// alias - This is the only method here that does anything interesting...
AliasAnalysis::Result DSAA::alias(const Value *V1, const Value *V2) {
AliasAnalysis::AliasResult DSAA::alias(const Value *V1, unsigned V1Size,
const Value *V2, unsigned V2Size) {
// FIXME: This should handle the Size argument as well!
const Function *F1 = getValueFunction(V1);
const Function *F2 = getValueFunction(V2);
assert((!F1 || !F2 || F1 == F2) && "Alias query for 2 different functions?");
@ -113,5 +106,5 @@ AliasAnalysis::Result DSAA::alias(const Value *V1, const Value *V2) {
// FIXME: we could improve on this by checking the globals graph for aliased
// global queries...
return getAnalysis<AliasAnalysis>().alias(V1, V2);
return getAnalysis<AliasAnalysis>().alias(V1, V1Size, V2, V2Size);
}

View File

@ -18,7 +18,7 @@ namespace {
DSGraph *ResultGraph;
DSGraph *GlobalsGraph; // FIXME: Eliminate globals graph stuff from DNE
public:
Steens() : ResultGraph(0) {}
Steens() : ResultGraph(0), GlobalsGraph(0) {}
~Steens() {
releaseMyMemory();
assert(ResultGraph == 0 && "releaseMemory not called?");
@ -36,6 +36,7 @@ namespace {
virtual void releaseMyMemory() { delete ResultGraph; ResultGraph = 0; }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AliasAnalysis::getAnalysisUsage(AU);
AU.setPreservesAll(); // Does not transform code...
AU.addRequired<LocalDataStructures>(); // Uses local dsgraph
AU.addRequired<AliasAnalysis>(); // Chains to another AA impl...
@ -52,19 +53,8 @@ namespace {
//
// alias - This is the only method here that does anything interesting...
Result alias(const Value *V1, const Value *V2);
/// canCallModify - Not implemented yet: FIXME
///
Result canCallModify(const CallInst &CI, const Value *Ptr) {
return MayAlias;
}
/// canInvokeModify - Not implemented yet: FIXME
///
Result canInvokeModify(const InvokeInst &I, const Value *Ptr) {
return MayAlias;
}
AliasResult alias(const Value *V1, unsigned V1Size,
const Value *V2, unsigned V2Size);
private:
void ResolveFunctionCall(Function *F, const DSCallSite &Call,
@ -108,6 +98,7 @@ void Steens::ResolveFunctionCall(Function *F, const DSCallSite &Call,
/// program.
///
bool Steens::run(Module &M) {
InitializeAliasAnalysis(this);
assert(ResultGraph == 0 && "Result graph already allocated!");
LocalDataStructures &LDS = getAnalysis<LocalDataStructures>();
@ -212,7 +203,9 @@ bool Steens::run(Module &M) {
}
// alias - This is the only method here that does anything interesting...
AliasAnalysis::Result Steens::alias(const Value *V1, const Value *V2) {
AliasAnalysis::AliasResult Steens::alias(const Value *V1, unsigned V1Size,
const Value *V2, unsigned V2Size) {
// FIXME: HANDLE Size argument!
assert(ResultGraph && "Result graph has not been computed yet!");
hash_map<Value*, DSNodeHandle> &GSM = ResultGraph->getScalarMap();
@ -239,5 +232,5 @@ AliasAnalysis::Result Steens::alias(const Value *V1, const Value *V2) {
// If we cannot determine alias properties based on our graph, fall back on
// some other AA implementation.
//
return getAnalysis<AliasAnalysis>().alias(V1, V2);
return getAnalysis<AliasAnalysis>().alias(V1, V1Size, V2, V2Size);
}