Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. //===- ScalarEvolutionAliasAnalysis.h - SCEV-based AA -----------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. /// \file
  9. /// This is the interface for a SCEV-based alias analysis.
  10. ///
  11. //===----------------------------------------------------------------------===//
  12.  
  13. #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONALIASANALYSIS_H
  14. #define LLVM_ANALYSIS_SCALAREVOLUTIONALIASANALYSIS_H
  15.  
  16. #include "llvm/Analysis/AliasAnalysis.h"
  17. #include "llvm/Pass.h"
  18.  
  19. namespace llvm {
  20.  
  21. class Function;
  22. class ScalarEvolution;
  23. class SCEV;
  24.  
  25. /// A simple alias analysis implementation that uses ScalarEvolution to answer
  26. /// queries.
  27. class SCEVAAResult : public AAResultBase {
  28.   ScalarEvolution &SE;
  29.  
  30. public:
  31.   explicit SCEVAAResult(ScalarEvolution &SE) : SE(SE) {}
  32.   SCEVAAResult(SCEVAAResult &&Arg) : AAResultBase(std::move(Arg)), SE(Arg.SE) {}
  33.  
  34.   AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
  35.                     AAQueryInfo &AAQI, const Instruction *CtxI);
  36.  
  37.   bool invalidate(Function &F, const PreservedAnalyses &PA,
  38.                   FunctionAnalysisManager::Invalidator &Inv);
  39.  
  40. private:
  41.   Value *GetBaseValue(const SCEV *S);
  42. };
  43.  
  44. /// Analysis pass providing a never-invalidated alias analysis result.
  45. class SCEVAA : public AnalysisInfoMixin<SCEVAA> {
  46.   friend AnalysisInfoMixin<SCEVAA>;
  47.   static AnalysisKey Key;
  48.  
  49. public:
  50.   typedef SCEVAAResult Result;
  51.  
  52.   SCEVAAResult run(Function &F, FunctionAnalysisManager &AM);
  53. };
  54.  
  55. /// Legacy wrapper pass to provide the SCEVAAResult object.
  56. class SCEVAAWrapperPass : public FunctionPass {
  57.   std::unique_ptr<SCEVAAResult> Result;
  58.  
  59. public:
  60.   static char ID;
  61.  
  62.   SCEVAAWrapperPass();
  63.  
  64.   SCEVAAResult &getResult() { return *Result; }
  65.   const SCEVAAResult &getResult() const { return *Result; }
  66.  
  67.   bool runOnFunction(Function &F) override;
  68.   void getAnalysisUsage(AnalysisUsage &AU) const override;
  69. };
  70.  
  71. /// Creates an instance of \c SCEVAAWrapperPass.
  72. FunctionPass *createSCEVAAWrapperPass();
  73.  
  74. }
  75.  
  76. #endif
  77.