50 unsigned NoAliasCount, MayAliasCount, PartialAliasCount, MustAliasCount;
51 unsigned NoModRefCount, ModCount, RefCount, ModRefCount;
64 bool doInitialization(
Module &M)
override {
65 NoAliasCount = MayAliasCount = PartialAliasCount = MustAliasCount = 0;
66 NoModRefCount = ModCount = RefCount = ModRefCount = 0;
77 bool doFinalization(
Module &M)
override;
83 "Exhaustive Alias Analysis Precision Evaluator",
false,
true)
102 errs() <<
" " << Msg <<
":\t"
112 errs() <<
" " << Msg <<
": Ptr: ";
114 errs() <<
"\t<->" << *I <<
'\n';
131 errs() <<
" " << Msg <<
": " << *V1
132 <<
" <-> " << *V2 <<
'\n';
138 && !isa<ConstantPointerNull>(V);
141 bool AAEval::runOnFunction(
Function &
F) {
150 if (
I->getType()->isPointerTy())
154 if (
I->getType()->isPointerTy())
155 Pointers.insert(&*
I);
162 Value *Callee =
CS.getCalledValue();
165 Pointers.insert(Callee);
170 Pointers.insert(*AI);
177 Pointers.insert(*OI);
184 <<
" pointers, " << CallSites.
size() <<
" call sites\n";
190 Type *I1ElTy = cast<PointerType>((*I1)->getType())->getElementType();
195 Type *I2ElTy =cast<PointerType>((*I2)->getType())->getElementType();
198 switch (AA.
alias(*I1, I1Size, *I2, I2Size)) {
285 Ce = CallSites.
end();
C != Ce; ++
C) {
291 Type *ElTy = cast<PointerType>((*V)->getType())->getElementType();
317 Ce = CallSites.
end();
C != Ce; ++
C) {
346 errs() <<
"(" << Num*100ULL/Sum <<
"."
347 << ((Num*1000ULL/Sum) % 10) <<
"%)\n";
350 bool AAEval::doFinalization(
Module &M) {
352 NoAliasCount + MayAliasCount + PartialAliasCount + MustAliasCount;
353 errs() <<
"===== Alias Analysis Evaluator Report =====\n";
355 errs() <<
" Alias Analysis Evaluator Summary: No pointers!\n";
357 errs() <<
" " << AliasSum <<
" Total Alias Queries Performed\n";
358 errs() <<
" " << NoAliasCount <<
" no alias responses ";
360 errs() <<
" " << MayAliasCount <<
" may alias responses ";
362 errs() <<
" " << PartialAliasCount <<
" partial alias responses ";
364 errs() <<
" " << MustAliasCount <<
" must alias responses ";
366 errs() <<
" Alias Analysis Evaluator Pointer Alias Summary: "
367 << NoAliasCount * 100 / AliasSum <<
"%/"
368 << MayAliasCount * 100 / AliasSum <<
"%/"
369 << PartialAliasCount * 100 / AliasSum <<
"%/"
370 << MustAliasCount * 100 / AliasSum <<
"%\n";
374 unsigned ModRefSum = NoModRefCount + ModCount + RefCount + ModRefCount;
375 if (ModRefSum == 0) {
376 errs() <<
" Alias Analysis Mod/Ref Evaluator Summary: no "
379 errs() <<
" " << ModRefSum <<
" Total ModRef Queries Performed\n";
380 errs() <<
" " << NoModRefCount <<
" no mod/ref responses ";
382 errs() <<
" " << ModCount <<
" mod responses ";
384 errs() <<
" " << RefCount <<
" ref responses ";
386 errs() <<
" " << ModRefCount <<
" mod & ref responses ";
388 errs() <<
" Alias Analysis Evaluator Mod/Ref Summary: "
389 << NoModRefCount * 100 / ModRefSum <<
"%/"
390 << ModCount * 100 / ModRefSum <<
"%/" << RefCount * 100 / ModRefSum
391 <<
"%/" << ModRefCount * 100 / ModRefSum <<
"%\n";
The two locations precisely alias each other.
static cl::opt< bool > PrintPartialAlias("print-partial-aliases", cl::ReallyHidden)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
size_t size() const
size - Get the string size.
A Module instance is used to store all the information related to an LLVM module. ...
InstrTy * getInstruction() const
The two locations alias, but only due to a partial overlap.
static void PrintModRefResults(const char *Msg, bool P, Instruction *I, Value *Ptr, Module *M)
static cl::opt< bool > PrintMod("print-mod", cl::ReallyHidden)
static cl::opt< bool > PrintModRef("print-modref", cl::ReallyHidden)
The two locations do not alias at all.
FunctionPass * createAAEvalPass()
User::op_iterator arg_iterator
arg_iterator - The type of iterator to use when looping over actual arguments at this call site...
iterator end()
Get an iterator to the end of the SetVector.
size_type size() const
Determine the number of elements in the SetVector.
The two locations may or may not alias. This is the least precise result.
aa Exhaustive Alias Analysis Precision false
static cl::opt< bool > PrintMustAlias("print-must-aliases", cl::ReallyHidden)
StringRef getName() const
Return a constant reference to the value's name.
AnalysisUsage & addRequired()
inst_iterator inst_begin(Function *F)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
bool isSized(SmallPtrSetImpl< const Type * > *Visited=nullptr) const
isSized - Return true if it makes sense to take the size of this type.
load Combine Adjacent Loads
bool insert(const value_type &X)
Insert a new element into the SetVector.
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
iterator begin()
Get an iterator to the beginning of the SetVector.
uint64_t getTypeStoreSize(Type *Ty)
getTypeStoreSize - Return the DataLayout store size for the given type, if known, or a conservative v...
static void PrintResults(const char *Msg, bool P, const Value *V1, const Value *V2, const Module *M)
static void PrintLoadStoreResults(const char *Msg, bool P, const Value *V1, const Value *V2, const Module *M)
aa Exhaustive Alias Analysis Precision Evaluator
static bool isInterestingPointer(Value *V)
static cl::opt< bool > PrintRef("print-ref", cl::ReallyHidden)
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
The instances of the Type class are immutable: once they are created, they are never changed...
static cl::opt< bool > PrintMayAlias("print-may-aliases", cl::ReallyHidden)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
#define INITIALIZE_AG_DEPENDENCY(depName)
bool isPointerTy() const
isPointerTy - True if this is an instance of PointerType.
void initializeAAEvalPass(PassRegistry &)
virtual AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
Alias Queries...
Type * getType() const
All values are typed, get the type of this value.
ModRefResult getModRefInfo(const Instruction *I)
getModRefInfo - Return information about whether or not an instruction may read or write memory (with...
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
void setPreservesAll()
Set by analyses that do not transform their input at all.
block Block Frequency Analysis
INITIALIZE_PASS_BEGIN(AAEval,"aa-eval","Exhaustive Alias Analysis Precision Evaluator", false, true) INITIALIZE_PASS_END(AAEval
static cl::opt< bool > EvalAAMD("evaluate-aa-metadata", cl::ReallyHidden)
static cl::opt< bool > PrintNoModRef("print-no-modref", cl::ReallyHidden)
A raw_ostream that writes to an std::string.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
vector_type::const_iterator iterator
A vector that has set insertion semantics.
static void PrintPercent(unsigned Num, unsigned Sum)
C - The default llvm calling convention, compatible with C.
inst_iterator inst_end(Function *F)
static cl::opt< bool > PrintAll("print-all-alias-modref-info", cl::ReallyHidden)
static cl::opt< bool > PrintNoAlias("print-no-aliases", cl::ReallyHidden)