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/Metadata.h"
21 #include "llvm/IR/Module.h"
22 #include "llvm/Pass.h"
26 /// ScalarEvolutionAliasAnalysis - This is a simple alias analysis
27 /// implementation that uses ScalarEvolution to answer queries.
28 class ScalarEvolutionAliasAnalysis : public FunctionPass, public AliasAnalysis {
32 static char ID; // Class identification, replacement for typeinfo
33 ScalarEvolutionAliasAnalysis() : FunctionPass(ID), SE(nullptr) {
34 initializeScalarEvolutionAliasAnalysisPass(
35 *PassRegistry::getPassRegistry());
38 /// getAdjustedAnalysisPointer - This method is used when a pass implements
39 /// an analysis interface through multiple inheritance. If needed, it
40 /// should override this to adjust the this pointer as needed for the
41 /// specified pass info.
42 void *getAdjustedAnalysisPointer(AnalysisID PI) override {
43 if (PI == &AliasAnalysis::ID)
44 return (AliasAnalysis *)this;
49 void getAnalysisUsage(AnalysisUsage &AU) const override;
50 bool runOnFunction(Function &F) override;
51 AliasResult alias(const MemoryLocation &LocA,
52 const MemoryLocation &LocB) override;
54 Value *GetBaseValue(const SCEV *S);
57 //===--------------------------------------------------------------------===//
59 // createScalarEvolutionAliasAnalysisPass - This pass implements a simple
60 // alias analysis using ScalarEvolution queries.
62 FunctionPass *createScalarEvolutionAliasAnalysisPass();