LLVM  3.7.0
ObjCARCAliasAnalysis.h
Go to the documentation of this file.
1 //===- ObjCARCAliasAnalysis.h - ObjC ARC Optimization -*- C++ -*-----------===//
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 /// \file
10 /// This file declares a simple ARC-aware AliasAnalysis using special knowledge
11 /// of Objective C to enhance other optimization passes which rely on the Alias
12 /// Analysis infrastructure.
13 ///
14 /// WARNING: This file knows about certain library functions. It recognizes them
15 /// by name, and hardwires knowledge of their semantics.
16 ///
17 /// WARNING: This file knows about how certain Objective-C library functions are
18 /// used. Naive LLVM IR transformations which would otherwise be
19 /// behavior-preserving may break these assumptions.
20 ///
21 //===----------------------------------------------------------------------===//
22 
23 #ifndef LLVM_LIB_TRANSFORMS_OBJCARC_OBJCARCALIASANALYSIS_H
24 #define LLVM_LIB_TRANSFORMS_OBJCARC_OBJCARCALIASANALYSIS_H
25 
27 #include "llvm/Pass.h"
28 
29 namespace llvm {
30 namespace objcarc {
31 
32  /// \brief This is a simple alias analysis implementation that uses knowledge
33  /// of ARC constructs to answer queries.
34  ///
35  /// TODO: This class could be generalized to know about other ObjC-specific
36  /// tricks. Such as knowing that ivars in the non-fragile ABI are non-aliasing
37  /// even though their offsets are dynamic.
39  public AliasAnalysis {
40  public:
41  static char ID; // Class identification, replacement for typeinfo
44  }
45 
46  private:
47  bool doInitialization(Module &M) override;
48 
49  /// This method is used when a pass implements an analysis interface through
50  /// multiple inheritance. If needed, it should override this to adjust the
51  /// this pointer as needed for the specified pass info.
52  void *getAdjustedAnalysisPointer(const void *PI) override {
53  if (PI == &AliasAnalysis::ID)
54  return static_cast<AliasAnalysis *>(this);
55  return this;
56  }
57 
58  void getAnalysisUsage(AnalysisUsage &AU) const override;
59  AliasResult alias(const MemoryLocation &LocA,
60  const MemoryLocation &LocB) override;
61  bool pointsToConstantMemory(const MemoryLocation &Loc,
62  bool OrLocal) override;
63  ModRefBehavior getModRefBehavior(ImmutableCallSite CS) override;
64  ModRefBehavior getModRefBehavior(const Function *F) override;
65  ModRefResult getModRefInfo(ImmutableCallSite CS,
66  const MemoryLocation &Loc) override;
67  ModRefResult getModRefInfo(ImmutableCallSite CS1,
68  ImmutableCallSite CS2) override;
69  };
70 
71 } // namespace objcarc
72 } // namespace llvm
73 
74 #endif
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
ModRefBehavior
ModRefBehavior - Summary of how a function affects memory in the program.
F(f)
void initializeObjCARCAliasAnalysisPass(PassRegistry &)
This is a simple alias analysis implementation that uses knowledge of ARC constructs to answer querie...
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
ImmutableCallSite - establish a view to a call site for examination.
Definition: CallSite.h:418
ModRefResult
Simple mod/ref information...