LLVM  3.7.0
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/IR/LLVMContext.h"
19 #include "llvm/IR/Module.h"
20 #include "llvm/Pass.h"
21 using namespace llvm;
22 
23 namespace {
24  /// NoAA - This class implements the -no-aa pass, which always returns "I
25  /// don't know" for alias queries. NoAA is unlike other alias analysis
26  /// implementations, in that it does not chain to a previous analysis. As
27  /// such it doesn't follow many of the rules that other alias analyses must.
28  ///
29  struct NoAA : public ImmutablePass, public AliasAnalysis {
30  static char ID; // Class identification, replacement for typeinfo
31  NoAA() : ImmutablePass(ID) {
33  }
34 
35  void getAnalysisUsage(AnalysisUsage &AU) const override {}
36 
37  bool doInitialization(Module &M) override {
38  // Note: NoAA does not call InitializeAliasAnalysis because it's
39  // special and does not support chaining.
40  DL = &M.getDataLayout();
41  return true;
42  }
43 
44  AliasResult alias(const MemoryLocation &LocA,
45  const MemoryLocation &LocB) override {
46  return MayAlias;
47  }
48 
49  ModRefBehavior getModRefBehavior(ImmutableCallSite CS) override {
50  return UnknownModRefBehavior;
51  }
52  ModRefBehavior getModRefBehavior(const Function *F) override {
53  return UnknownModRefBehavior;
54  }
55 
56  bool pointsToConstantMemory(const MemoryLocation &Loc,
57  bool OrLocal) override {
58  return false;
59  }
60  ModRefResult getArgModRefInfo(ImmutableCallSite CS,
61  unsigned ArgIdx) override {
62  return ModRef;
63  }
64 
65  ModRefResult getModRefInfo(ImmutableCallSite CS,
66  const MemoryLocation &Loc) override {
67  return ModRef;
68  }
69  ModRefResult getModRefInfo(ImmutableCallSite CS1,
70  ImmutableCallSite CS2) override {
71  return ModRef;
72  }
73 
74  void deleteValue(Value *V) override {}
75  void addEscapingUse(Use &U) override {}
76 
77  /// getAdjustedAnalysisPointer - This method is used when a pass implements
78  /// an analysis interface through multiple inheritance. If needed, it
79  /// should override this to adjust the this pointer as needed for the
80  /// specified pass info.
81  void *getAdjustedAnalysisPointer(const void *ID) override {
82  if (ID == &AliasAnalysis::ID)
83  return (AliasAnalysis*)this;
84  return this;
85  }
86  };
87 } // End of anonymous namespace
88 
89 // Register this pass...
90 char NoAA::ID = 0;
92  "No Alias Analysis (always returns 'may' alias)",
93  true, true, true)
94 
95 ImmutablePass *llvm::createNoAAPass() { return new NoAA(); }
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
F(f)
The two locations may or may not alias. This is the least precise result.
Definition: AliasAnalysis.h:80
ImmutablePass * createNoAAPass()
A Use represents the edge between a Value definition and its users.
Definition: Use.h:69
void initializeNoAAPass(PassRegistry &)
#define ModRefBehavior
AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:72
Represent the analysis usage information of a pass.
Representation for a specific memory location.
ImmutablePass class - This class is used to provide information that does not need to be run...
Definition: Pass.h:262
Module.h This file contains the declarations for the Module class.
INITIALIZE_AG_PASS(NoAA, AliasAnalysis,"no-aa","No Alias Analysis (always returns 'may' alias)", true, true, true) ImmutablePass *llvm
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:372
ImmutableCallSite - establish a view to a call site for examination.
Definition: CallSite.h:418
LLVM Value Representation.
Definition: Value.h:69