Fixed some bugs.
[llvm/zpu.git] / lib / Analysis / NoAliasAnalysis.cpp
blob7602149edc042c308d44fa2682fed57a4cf76c94
1 //===- NoAliasAnalysis.cpp - Minimal Alias Analysis Impl ------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the default implementation of the Alias Analysis interface
11 // that simply returns "I don't know" for all queries.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/Analysis/AliasAnalysis.h"
16 #include "llvm/Analysis/Passes.h"
17 #include "llvm/Pass.h"
18 #include "llvm/Target/TargetData.h"
19 using namespace llvm;
21 namespace {
22 /// NoAA - This class implements the -no-aa pass, which always returns "I
23 /// don't know" for alias queries. NoAA is unlike other alias analysis
24 /// implementations, in that it does not chain to a previous analysis. As
25 /// such it doesn't follow many of the rules that other alias analyses must.
26 ///
27 struct NoAA : public ImmutablePass, public AliasAnalysis {
28 static char ID; // Class identification, replacement for typeinfo
29 NoAA() : ImmutablePass(ID) {
30 initializeNoAAPass(*PassRegistry::getPassRegistry());
33 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
36 virtual void initializePass() {
37 // Note: NoAA does not call InitializeAliasAnalysis because it's
38 // special and does not support chaining.
39 TD = getAnalysisIfAvailable<TargetData>();
42 virtual AliasResult alias(const Location &LocA, const Location &LocB) {
43 return MayAlias;
46 virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS) {
47 return UnknownModRefBehavior;
49 virtual ModRefBehavior getModRefBehavior(const Function *F) {
50 return UnknownModRefBehavior;
53 virtual bool pointsToConstantMemory(const Location &Loc) { return false; }
54 virtual ModRefResult getModRefInfo(ImmutableCallSite CS,
55 const Location &Loc) {
56 return ModRef;
58 virtual ModRefResult getModRefInfo(ImmutableCallSite CS1,
59 ImmutableCallSite CS2) {
60 return ModRef;
63 virtual void deleteValue(Value *V) {}
64 virtual void copyValue(Value *From, Value *To) {}
66 /// getAdjustedAnalysisPointer - This method is used when a pass implements
67 /// an analysis interface through multiple inheritance. If needed, it
68 /// should override this to adjust the this pointer as needed for the
69 /// specified pass info.
70 virtual void *getAdjustedAnalysisPointer(const void *ID) {
71 if (ID == &AliasAnalysis::ID)
72 return (AliasAnalysis*)this;
73 return this;
76 } // End of anonymous namespace
78 // Register this pass...
79 char NoAA::ID = 0;
80 INITIALIZE_AG_PASS(NoAA, AliasAnalysis, "no-aa",
81 "No Alias Analysis (always returns 'may' alias)",
82 true, true, true)
84 ImmutablePass *llvm::createNoAAPass() { return new NoAA(); }