forked from OSchip/llvm-project
parent
4a09234cb7
commit
77351ba3ae
|
@ -52,13 +52,8 @@ public:
|
||||||
AliasResult query(const MemoryLocation &LocA, const MemoryLocation &LocB);
|
AliasResult query(const MemoryLocation &LocA, const MemoryLocation &LocB);
|
||||||
|
|
||||||
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
|
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
|
||||||
if (LocA.Ptr == LocB.Ptr) {
|
if (LocA.Ptr == LocB.Ptr)
|
||||||
if (LocA.Size == LocB.Size) {
|
return LocA.Size == LocB.Size ? MustAlias : PartialAlias;
|
||||||
return MustAlias;
|
|
||||||
} else {
|
|
||||||
return PartialAlias;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comparisons between global variables and other constants should be
|
// Comparisons between global variables and other constants should be
|
||||||
// handled by BasicAA.
|
// handled by BasicAA.
|
||||||
|
@ -66,9 +61,8 @@ public:
|
||||||
// a GlobalValue and ConstantExpr, but every query needs to have at least
|
// a GlobalValue and ConstantExpr, but every query needs to have at least
|
||||||
// one Value tied to a Function, and neither GlobalValues nor ConstantExprs
|
// one Value tied to a Function, and neither GlobalValues nor ConstantExprs
|
||||||
// are.
|
// are.
|
||||||
if (isa<Constant>(LocA.Ptr) && isa<Constant>(LocB.Ptr)) {
|
if (isa<Constant>(LocA.Ptr) && isa<Constant>(LocB.Ptr))
|
||||||
return AAResultBase::alias(LocA, LocB);
|
return AAResultBase::alias(LocA, LocB);
|
||||||
}
|
|
||||||
|
|
||||||
AliasResult QueryResult = query(LocA, LocB);
|
AliasResult QueryResult = query(LocA, LocB);
|
||||||
if (QueryResult == MayAlias)
|
if (QueryResult == MayAlias)
|
||||||
|
|
|
@ -23,10 +23,16 @@
|
||||||
// Because this algorithm requires a graph search on each query, we execute the
|
// Because this algorithm requires a graph search on each query, we execute the
|
||||||
// algorithm outlined in "Fast algorithms..." (mentioned above)
|
// algorithm outlined in "Fast algorithms..." (mentioned above)
|
||||||
// in order to transform the graph into sets of variables that may alias in
|
// in order to transform the graph into sets of variables that may alias in
|
||||||
// ~nlogn time (n = number of variables.), which makes queries take constant
|
// ~nlogn time (n = number of variables), which makes queries take constant
|
||||||
// time.
|
// time.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// N.B. AliasAnalysis as a whole is phrased as a FunctionPass at the moment, and
|
||||||
|
// CFLAA is interprocedural. This is *technically* A Bad Thing, because
|
||||||
|
// FunctionPasses are only allowed to inspect the Function that they're being
|
||||||
|
// run on. Realistically, this likely isn't a problem until we allow
|
||||||
|
// FunctionPasses to run concurrently.
|
||||||
|
|
||||||
#include "llvm/Analysis/CFLAliasAnalysis.h"
|
#include "llvm/Analysis/CFLAliasAnalysis.h"
|
||||||
#include "StratifiedSets.h"
|
#include "StratifiedSets.h"
|
||||||
#include "llvm/ADT/BitVector.h"
|
#include "llvm/ADT/BitVector.h"
|
||||||
|
@ -200,9 +206,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void visitPHINode(PHINode &Inst) {
|
void visitPHINode(PHINode &Inst) {
|
||||||
for (Value *Val : Inst.incoming_values()) {
|
for (Value *Val : Inst.incoming_values())
|
||||||
Output.push_back(Edge(&Inst, Val, EdgeType::Assign, AttrNone));
|
Output.push_back(Edge(&Inst, Val, EdgeType::Assign, AttrNone));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void visitGetElementPtrInst(GetElementPtrInst &Inst) {
|
void visitGetElementPtrInst(GetElementPtrInst &Inst) {
|
||||||
|
@ -275,7 +280,7 @@ public:
|
||||||
Current = &Sets.getLink(Current->Above);
|
Current = &Sets.getLink(Current->Above);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NoneType();
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -687,7 +692,7 @@ static Optional<Function *> parentFunctionOfValue(Value *Val) {
|
||||||
|
|
||||||
if (auto *Arg = dyn_cast<Argument>(Val))
|
if (auto *Arg = dyn_cast<Argument>(Val))
|
||||||
return Arg->getParent();
|
return Arg->getParent();
|
||||||
return NoneType();
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Inst>
|
template <typename Inst>
|
||||||
|
@ -731,7 +736,7 @@ static Optional<StratifiedAttr> valueToAttrIndex(Value *Val) {
|
||||||
// cast, and thus, interaction with them doesn't matter.
|
// cast, and thus, interaction with them doesn't matter.
|
||||||
if (!Arg->hasNoAliasAttr() && Arg->getType()->isPointerTy())
|
if (!Arg->hasNoAliasAttr() && Arg->getType()->isPointerTy())
|
||||||
return argNumberToAttrIndex(Arg->getArgNo());
|
return argNumberToAttrIndex(Arg->getArgNo());
|
||||||
return NoneType();
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static StratifiedAttr argNumberToAttrIndex(unsigned ArgNum) {
|
static StratifiedAttr argNumberToAttrIndex(unsigned ArgNum) {
|
||||||
|
|
Loading…
Reference in New Issue