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 ScalarEvolutionAliasAnalysis : public FunctionPass, public AliasAnalysis {
31 static char ID; // Class identification, replacement for typeinfo
32 ScalarEvolutionAliasAnalysis() : FunctionPass(ID), SE(nullptr) {
33 initializeScalarEvolutionAliasAnalysisPass(
34 *PassRegistry::getPassRegistry());
37 /// This method is used when a pass implements an analysis interface through
38 /// multiple inheritance.
40 /// If needed, it should override this to adjust the this pointer as needed
41 /// for the 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 /// Creates an instance of \c ScalarEvolutionAliasAnalysis.
58 FunctionPass *createScalarEvolutionAliasAnalysisPass();