From 7ccc4c2ed96a07d0977b097f73fdc86b3cb295dd Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 23 May 2004 21:15:12 +0000 Subject: [PATCH] Move the -no-aa AA implementation into this file since both of these alias analysis implementations are special: they do not autoforward to a chained implementation of alias analysis llvm-svn: 13683 --- lib/Analysis/BasicAliasAnalysis.cpp | 54 ++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 8fc561ea1d9..5ccaa5c66c6 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -36,13 +36,55 @@ using namespace llvm; void llvm::BasicAAStub() {} namespace { - struct BasicAliasAnalysis : public ImmutablePass, public AliasAnalysis { - + /// NoAA - This class implements the -no-aa pass, which always returns "I + /// don't know" for alias queries. NoAA is unlike other alias analysis + /// implementations, in that it does not chain to a previous analysis. As + /// such it doesn't follow many of the rules that other alias analyses must. + /// + struct NoAA : public ImmutablePass, public AliasAnalysis { + virtual AliasResult alias(const Value *V1, unsigned V1Size, + const Value *V2, unsigned V2Size) { + return MayAlias; + } + + virtual void getMustAliases(Value *P, std::vector &RetVals) { } + virtual bool pointsToConstantMemory(const Value *P) { return false; } + virtual bool doesNotAccessMemory(Function *F) { return false; } + virtual bool onlyReadsMemory(Function *F) { return false; } + virtual ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size) { + return ModRef; + } + virtual ModRefResult getModRefInfo(CallSite CS1, CallSite CS2) { + return ModRef; + } + virtual bool hasNoModRefInfoForCalls() const { return true; } + + virtual void deleteValue(Value *V) {} + virtual void copyValue(Value *From, Value *To) {} + virtual void getAnalysisUsage(AnalysisUsage &AU) const {} + }; + + // Register this pass... + RegisterOpt + U("no-aa", "No Alias Analysis (always returns 'may' alias)"); + + // Declare that we implement the AliasAnalysis interface + RegisterAnalysisGroup V; +} // End of anonymous namespace + + +namespace { + /// BasicAliasAnalysis - This is the default alias analysis implementation. + /// Because it doesn't chain to a previous alias analysis (like -no-aa), it + /// derives from the NoAA class. + struct BasicAliasAnalysis : public NoAA { virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AliasAnalysis::getAnalysisUsage(AU); + AU.addRequired(); } - virtual void initializePass(); + virtual void initializePass() { + TD = &getAnalysis(); + } AliasResult alias(const Value *V1, unsigned V1Size, const Value *V2, unsigned V2Size); @@ -79,10 +121,6 @@ namespace { RegisterAnalysisGroup Y; } // End of anonymous namespace -void BasicAliasAnalysis::initializePass() { - InitializeAliasAnalysis(this); -} - // hasUniqueAddress - Return true if the specified value points to something // with a unique, discernable, address. static inline bool hasUniqueAddress(const Value *V) {