Home | History | Annotate | Download | only in Analysis
      1 //=- CFLAndersAliasAnalysis.h - Unification-based 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 is the interface for LLVM's inclusion-based alias analysis
     11 /// implemented with CFL graph reachability.
     12 ///
     13 //===----------------------------------------------------------------------===//
     14 
     15 #ifndef LLVM_ANALYSIS_CFLANDERSALIASANALYSIS_H
     16 #define LLVM_ANALYSIS_CFLANDERSALIASANALYSIS_H
     17 
     18 #include "llvm/Analysis/AliasAnalysis.h"
     19 #include "llvm/IR/Function.h"
     20 #include "llvm/Pass.h"
     21 
     22 namespace llvm {
     23 
     24 namespace cflaa {
     25 struct AliasSummary;
     26 }
     27 
     28 class CFLAndersAAResult : public AAResultBase<CFLAndersAAResult> {
     29   friend AAResultBase<CFLAndersAAResult>;
     30 
     31 public:
     32   explicit CFLAndersAAResult();
     33 
     34   /// \brief Get the alias summary for the given function
     35   /// Return nullptr if the summary is not found or not available
     36   const cflaa::AliasSummary *getAliasSummary(Function &Fn) {
     37     // Dummy implementation
     38     return nullptr;
     39   }
     40 
     41   AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
     42     // Dummy implementation
     43     return AAResultBase::alias(LocA, LocB);
     44   }
     45 };
     46 
     47 /// Analysis pass providing a never-invalidated alias analysis result.
     48 ///
     49 /// FIXME: We really should refactor CFL to use the analysis more heavily, and
     50 /// in particular to leverage invalidation to trigger re-computation.
     51 class CFLAndersAA : public AnalysisInfoMixin<CFLAndersAA> {
     52   friend AnalysisInfoMixin<CFLAndersAA>;
     53   static char PassID;
     54 
     55 public:
     56   typedef CFLAndersAAResult Result;
     57 
     58   CFLAndersAAResult run(Function &F, AnalysisManager<Function> &AM);
     59 };
     60 
     61 /// Legacy wrapper pass to provide the CFLAndersAAResult object.
     62 class CFLAndersAAWrapperPass : public ImmutablePass {
     63   std::unique_ptr<CFLAndersAAResult> Result;
     64 
     65 public:
     66   static char ID;
     67 
     68   CFLAndersAAWrapperPass();
     69 
     70   CFLAndersAAResult &getResult() { return *Result; }
     71   const CFLAndersAAResult &getResult() const { return *Result; }
     72 
     73   void initializePass() override;
     74   void getAnalysisUsage(AnalysisUsage &AU) const override;
     75 };
     76 
     77 //===--------------------------------------------------------------------===//
     78 //
     79 // createCFLAndersAAWrapperPass - This pass implements a set-based approach to
     80 // alias analysis.
     81 //
     82 ImmutablePass *createCFLAndersAAWrapperPass();
     83 }
     84 
     85 #endif
     86