LLVM  8.0.1
ObjCARCAliasAnalysis.h
Go to the documentation of this file.
1 //===- ObjCARCAliasAnalysis.h - ObjC ARC Alias Analysis ---------*- 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_ANALYSIS_OBJCARCALIASANALYSIS_H
24 #define LLVM_ANALYSIS_OBJCARCALIASANALYSIS_H
25 
27 #include "llvm/Pass.h"
28 
29 namespace llvm {
30 namespace objcarc {
31 
32 /// 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.
38 class ObjCARCAAResult : public AAResultBase<ObjCARCAAResult> {
40 
41  const DataLayout &DL;
42 
43 public:
44  explicit ObjCARCAAResult(const DataLayout &DL) : AAResultBase(), DL(DL) {}
46  : AAResultBase(std::move(Arg)), DL(Arg.DL) {}
47 
48  /// Handle invalidation events from the new pass manager.
49  ///
50  /// By definition, this result is stateless and so remains valid.
53  return false;
54  }
55 
56  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
57  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal);
58 
61 
64 };
65 
66 /// Analysis pass providing a never-invalidated alias analysis result.
67 class ObjCARCAA : public AnalysisInfoMixin<ObjCARCAA> {
69  static AnalysisKey Key;
70 
71 public:
73 
75 };
76 
77 /// Legacy wrapper pass to provide the ObjCARCAAResult object.
79  std::unique_ptr<ObjCARCAAResult> Result;
80 
81 public:
82  static char ID;
83 
85 
86  ObjCARCAAResult &getResult() { return *Result; }
87  const ObjCARCAAResult &getResult() const { return *Result; }
88 
89  bool doInitialization(Module &M) override;
90  bool doFinalization(Module &M) override;
91  void getAnalysisUsage(AnalysisUsage &AU) const override;
92 };
93 
94 } // namespace objcarc
95 } // namespace llvm
96 
97 #endif
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
This class represents lattice values for constants.
Definition: AllocatorList.h:24
ObjCARCAAResult(ObjCARCAAResult &&Arg)
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
FunctionModRefBehavior getModRefBehavior(const CallBase *Call)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1014
F(f)
could call objc_release
Definition: BitVector.h:938
A CRTP-driven "mixin" base class to help implement the function alias analysis results concept...
Key
PAL metadata keys.
FunctionModRefBehavior
Summary of how a function affects memory in the program.
FunctionModRefBehavior getModRefBehavior(const Function *F)
AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:78
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:154
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:383
Represent the analysis usage information of a pass.
bool invalidate(Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
Handle invalidation events from the new pass manager.
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:256
const ObjCARCAAResult & getResult() const
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
This is a simple alias analysis implementation that uses knowledge of ARC constructs to answer querie...
amdgpu Simplify well known AMD library false Value Value * Arg
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc)
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:642
ObjCARCAAResult(const DataLayout &DL)
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc)
Legacy wrapper pass to provide the ObjCARCAAResult object.
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
A container for analyses that lazily runs them and caches their results.
Analysis pass providing a never-invalidated alias analysis result.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:71