1 //===- ScalarEvolutionAliasAnalysis.h - SCEV-based AA -----------*- 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 is the interface for a SCEV-based alias analysis.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONALIASANALYSIS_H
15 #define LLVM_ANALYSIS_SCALAREVOLUTIONALIASANALYSIS_H
17 #include "llvm/Analysis/AliasAnalysis.h"
18 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
19 #include "llvm/IR/Function.h"
20 #include "llvm/IR/Module.h"
21 #include "llvm/Pass.h"
25 /// A simple alias analysis implementation that uses ScalarEvolution to answer
27 class SCEVAAResult : public AAResultBase<SCEVAAResult> {
31 explicit SCEVAAResult(const TargetLibraryInfo &TLI, ScalarEvolution &SE)
32 : AAResultBase(TLI), SE(SE) {}
33 SCEVAAResult(SCEVAAResult &&Arg) : AAResultBase(std::move(Arg)), SE(Arg.SE) {}
35 AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
38 Value *GetBaseValue(const SCEV *S);
41 /// Analysis pass providing a never-invalidated alias analysis result.
44 typedef SCEVAAResult Result;
46 /// \brief Opaque, unique identifier for this analysis pass.
47 static void *ID() { return (void *)&PassID; }
49 SCEVAAResult run(Function &F, AnalysisManager<Function> *AM);
51 /// \brief Provide access to a name for this pass for debugging purposes.
52 static StringRef name() { return "SCEVAA"; }
58 /// Legacy wrapper pass to provide the SCEVAAResult object.
59 class SCEVAAWrapperPass : public FunctionPass {
60 std::unique_ptr<SCEVAAResult> Result;
67 SCEVAAResult &getResult() { return *Result; }
68 const SCEVAAResult &getResult() const { return *Result; }
70 bool runOnFunction(Function &F) override;
71 void getAnalysisUsage(AnalysisUsage &AU) const override;
74 /// Creates an instance of \c SCEVAAWrapperPass.
75 FunctionPass *createSCEVAAWrapperPass();