1 //===- ObjCARCAliasAnalysis.h - ObjC ARC Optimization -*- mode: c++ -*-----===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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.
14 /// WARNING: This file knows about certain library functions. It recognizes them
15 /// by name, and hardwires knowledge of their semantics.
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.
21 //===----------------------------------------------------------------------===//
23 #ifndef LLVM_TRANSFORMS_OBJCARC_OBJCARCALIASANALYSIS_H
24 #define LLVM_TRANSFORMS_OBJCARC_OBJCARCALIASANALYSIS_H
29 /// \brief This is a simple alias analysis implementation that uses knowledge
30 /// of ARC constructs to answer queries.
32 /// TODO: This class could be generalized to know about other ObjC-specific
33 /// tricks. Such as knowing that ivars in the non-fragile ABI are non-aliasing
34 /// even though their offsets are dynamic.
35 class ObjCARCAliasAnalysis : public ImmutablePass,
36 public AliasAnalysis {
38 static char ID; // Class identification, replacement for typeinfo
39 ObjCARCAliasAnalysis() : ImmutablePass(ID) {
40 initializeObjCARCAliasAnalysisPass(*PassRegistry::getPassRegistry());
44 virtual void initializePass() {
45 InitializeAliasAnalysis(this);
48 /// This method is used when a pass implements an analysis interface through
49 /// multiple inheritance. If needed, it should override this to adjust the
50 /// this pointer as needed for the specified pass info.
51 virtual void *getAdjustedAnalysisPointer(const void *PI) {
52 if (PI == &AliasAnalysis::ID)
53 return static_cast<AliasAnalysis *>(this);
57 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
58 virtual AliasResult alias(const Location &LocA, const Location &LocB);
59 virtual bool pointsToConstantMemory(const Location &Loc, bool OrLocal);
60 virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS);
61 virtual ModRefBehavior getModRefBehavior(const Function *F);
62 virtual ModRefResult getModRefInfo(ImmutableCallSite CS,
64 virtual ModRefResult getModRefInfo(ImmutableCallSite CS1,
65 ImmutableCallSite CS2);
68 } // namespace objcarc
71 #endif // LLVM_TRANSFORMS_OBJCARC_OBJCARCALIASANALYSIS_H