LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NoAliasAnalysis.cpp
Go to the documentation of this file.
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.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "llvm/Analysis/Passes.h"
17 #include "llvm/IR/DataLayout.h"
18 #include "llvm/Pass.h"
19 using namespace llvm;
20 
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) {
31  }
32 
33  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
34  }
35 
36  virtual void initializePass() {
37  // Note: NoAA does not call InitializeAliasAnalysis because it's
38  // special and does not support chaining.
39  TD = getAnalysisIfAvailable<DataLayout>();
40  }
41 
42  virtual AliasResult alias(const Location &LocA, const Location &LocB) {
43  return MayAlias;
44  }
45 
46  virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS) {
47  return UnknownModRefBehavior;
48  }
49  virtual ModRefBehavior getModRefBehavior(const Function *F) {
50  return UnknownModRefBehavior;
51  }
52 
53  virtual bool pointsToConstantMemory(const Location &Loc,
54  bool OrLocal) {
55  return false;
56  }
57  virtual ModRefResult getModRefInfo(ImmutableCallSite CS,
58  const Location &Loc) {
59  return ModRef;
60  }
61  virtual ModRefResult getModRefInfo(ImmutableCallSite CS1,
62  ImmutableCallSite CS2) {
63  return ModRef;
64  }
65 
66  virtual void deleteValue(Value *V) {}
67  virtual void copyValue(Value *From, Value *To) {}
68  virtual void addEscapingUse(Use &U) {}
69 
70  /// getAdjustedAnalysisPointer - This method is used when a pass implements
71  /// an analysis interface through multiple inheritance. If needed, it
72  /// should override this to adjust the this pointer as needed for the
73  /// specified pass info.
74  virtual void *getAdjustedAnalysisPointer(const void *ID) {
75  if (ID == &AliasAnalysis::ID)
76  return (AliasAnalysis*)this;
77  return this;
78  }
79  };
80 } // End of anonymous namespace
81 
82 // Register this pass...
83 char NoAA::ID = 0;
85  "No Alias Analysis (always returns 'may' alias)",
86  true, true, true)
87 
88 ImmutablePass *llvm::createNoAAPass() { return new NoAA(); }
static PassRegistry * getPassRegistry()
F(f)
ImmutablePass * createNoAAPass()
Definition: Use.h:60
ID
LLVM Calling Convention Representation.
Definition: CallingConv.h:26
void initializeNoAAPass(PassRegistry &)
#define ModRefBehavior
INITIALIZE_AG_PASS(NoAA, AliasAnalysis,"no-aa","No Alias Analysis (always returns 'may' alias)", true, true, true) ImmutablePass *llvm
ImmutableCallSite - establish a view to a call site for examination.
Definition: CallSite.h:318
LLVM Value Representation.
Definition: Value.h:66
INITIALIZE_PASS(GlobalMerge,"global-merge","Global Merge", false, false) bool GlobalMerge const DataLayout * TD