Recommit [NFC] Better encapsulation of llvm::Optional Storage
[llvm-complete.git] / include / llvm / Analysis / ScalarEvolutionAliasAnalysis.h
blobd417850c0ee3fb5c623f4c0719e75d9eb86480e4
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 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONALIASANALYSIS_H
14 #define LLVM_ANALYSIS_SCALAREVOLUTIONALIASANALYSIS_H
16 #include "llvm/Analysis/AliasAnalysis.h"
17 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
18 #include "llvm/IR/Function.h"
19 #include "llvm/IR/Module.h"
20 #include "llvm/Pass.h"
22 namespace llvm {
24 /// A simple alias analysis implementation that uses ScalarEvolution to answer
25 /// queries.
26 class SCEVAAResult : public AAResultBase<SCEVAAResult> {
27 ScalarEvolution &SE;
29 public:
30 explicit SCEVAAResult(ScalarEvolution &SE) : AAResultBase(), SE(SE) {}
31 SCEVAAResult(SCEVAAResult &&Arg) : AAResultBase(std::move(Arg)), SE(Arg.SE) {}
33 AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
35 private:
36 Value *GetBaseValue(const SCEV *S);
39 /// Analysis pass providing a never-invalidated alias analysis result.
40 class SCEVAA : public AnalysisInfoMixin<SCEVAA> {
41 friend AnalysisInfoMixin<SCEVAA>;
42 static AnalysisKey Key;
44 public:
45 typedef SCEVAAResult Result;
47 SCEVAAResult run(Function &F, FunctionAnalysisManager &AM);
50 /// Legacy wrapper pass to provide the SCEVAAResult object.
51 class SCEVAAWrapperPass : public FunctionPass {
52 std::unique_ptr<SCEVAAResult> Result;
54 public:
55 static char ID;
57 SCEVAAWrapperPass();
59 SCEVAAResult &getResult() { return *Result; }
60 const SCEVAAResult &getResult() const { return *Result; }
62 bool runOnFunction(Function &F) override;
63 void getAnalysisUsage(AnalysisUsage &AU) const override;
66 /// Creates an instance of \c SCEVAAWrapperPass.
67 FunctionPass *createSCEVAAWrapperPass();
71 #endif