32 class ScalarEvolutionAliasAnalysis :
public FunctionPass,
47 void *getAdjustedAnalysisPointer(
AnalysisID PI)
override {
66 "ScalarEvolution-based Alias Analysis",
false,
true,
false)
72 return new ScalarEvolutionAliasAnalysis();
76 ScalarEvolutionAliasAnalysis::getAnalysisUsage(
AnalysisUsage &AU)
const {
83 ScalarEvolutionAliasAnalysis::runOnFunction(
Function &
F) {
85 SE = &getAnalysis<ScalarEvolution>();
92 ScalarEvolutionAliasAnalysis::GetBaseValue(
const SCEV *S) {
96 return GetBaseValue(AR->getStart());
97 }
else if (
const SCEVAddExpr *
A = dyn_cast<SCEVAddExpr>(S)) {
99 const SCEV *
Last =
A->getOperand(
A->getNumOperands()-1);
101 return GetBaseValue(Last);
102 }
else if (
const SCEVUnknown *U = dyn_cast<SCEVUnknown>(S)) {
104 return U->getValue();
115 if (LocA.
Size == 0 || LocB.
Size == 0)
119 const SCEV *AS = SE->getSCEV(const_cast<Value *>(LocA.
Ptr));
120 const SCEV *BS = SE->getSCEV(const_cast<Value *>(LocB.
Ptr));
127 if (SE->getEffectiveSCEVType(AS->
getType()) ==
128 SE->getEffectiveSCEVType(BS->
getType())) {
129 unsigned BitWidth = SE->getTypeSizeInBits(AS->
getType());
134 const SCEV *BA = SE->getMinusSCEV(BS, AS);
139 if (ASizeInt.ule(SE->getUnsignedRange(BA).getUnsignedMin()) &&
140 (-BSizeInt).uge(SE->getUnsignedRange(BA).getUnsignedMax()))
148 const SCEV *AB = SE->getMinusSCEV(AS, BS);
153 if (BSizeInt.ule(SE->getUnsignedRange(AB).getUnsignedMin()) &&
154 (-ASizeInt).uge(SE->getUnsignedRange(AB).getUnsignedMax()))
161 Value *AO = GetBaseValue(AS);
162 Value *BO = GetBaseValue(BS);
163 if ((AO && AO != LocA.
Ptr) || (BO && BO != LocB.
Ptr))
The two locations precisely alias each other.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
FunctionPass * createScalarEvolutionAliasAnalysisPass()
scev ScalarEvolution based Alias Analysis
ScalarEvolution - This class is the main scalar evolution driver.
void initializeScalarEvolutionAliasAnalysisPass(PassRegistry &)
The two locations do not alias at all.
#define INITIALIZE_PASS_DEPENDENCY(depName)
SCEVAddRecExpr - This node represents a polynomial recurrence on the trip count of the specified loop...
SCEVUnknown - This means that we are dealing with an entirely unknown SCEV value, and only represent ...
Type * getType() const
getType - Return the LLVM type of this SCEV expression.
AliasResult
The possible results of an alias query.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
bool isPointerTy() const
isPointerTy - True if this is an instance of PointerType.
scev ScalarEvolution based Alias false
const Value * Ptr
The address of the start of the location.
Representation for a specific memory location.
virtual AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
Alias Queries...
Module.h This file contains the declarations for the Module class.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
INITIALIZE_AG_PASS_BEGIN(ScalarEvolutionAliasAnalysis, AliasAnalysis,"scev-aa","ScalarEvolution-based Alias Analysis", false, true, false) INITIALIZE_AG_PASS_END(ScalarEvolutionAliasAnalysis
Class for arbitrary precision integers.
SCEVAddExpr - This node represents an addition of some number of SCEVs.
void setPreservesAll()
Set by analyses that do not transform their input at all.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
AAMDNodes AATags
The metadata nodes which describes the aliasing of the location (each member is null if that kind of ...
SCEV - This class represents an analyzed expression in the program.
AnalysisUsage & addRequiredTransitive()
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
scev ScalarEvolution based Alias true
virtual void getAnalysisUsage(AnalysisUsage &AU) const
getAnalysisUsage - All alias analysis implementations should invoke this directly (using AliasAnalysi...
#define INITIALIZE_AG_PASS_END(passName, agName, arg, n, cfg, analysis, def)
uint64_t Size
The maximum size of the location, in address-units, or UnknownSize if the size is not known...