51 unsigned NoAlias, MayAlias, PartialAlias, MustAlias;
52 unsigned NoModRef, Mod, Ref, ModRef;
65 bool doInitialization(
Module &M) {
66 NoAlias = MayAlias = PartialAlias = MustAlias = 0;
67 NoModRef = Mod = Ref = ModRef = 0;
78 bool doFinalization(
Module &M);
84 "Exhaustive Alias Analysis Precision Evaluator",
false,
true)
103 errs() <<
" " << Msg <<
":\t"
113 errs() <<
" " << Msg <<
": Ptr: ";
115 errs() <<
"\t<->" << *I <<
'\n';
132 errs() <<
" " << Msg <<
": " << *V1
133 <<
" <-> " << *V2 <<
'\n';
139 && !isa<ConstantPointerNull>(V);
142 bool AAEval::runOnFunction(
Function &
F) {
151 if (
I->getType()->isPointerTy())
155 if (
I->getType()->isPointerTy())
156 Pointers.insert(&*
I);
162 if (
CallSite CS = cast<Value>(&Inst)) {
163 Value *Callee = CS.getCalledValue();
166 Pointers.insert(Callee);
171 Pointers.insert(*AI);
178 Pointers.insert(*OI);
185 <<
" pointers, " << CallSites.
size() <<
" call sites\n";
191 Type *I1ElTy = cast<PointerType>((*I1)->getType())->getElementType();
196 Type *I2ElTy =cast<PointerType>((*I2)->getType())->getElementType();
199 switch (AA.
alias(*I1, I1Size, *I2, I2Size)) {
209 ++PartialAlias;
break;
236 ++PartialAlias;
break;
262 ++PartialAlias;
break;
274 Ce = CallSites.
end();
C != Ce; ++
C) {
280 Type *ElTy = cast<PointerType>((*V)->getType())->getElementType();
302 Ce = CallSites.
end();
C != Ce; ++
C) {
327 errs() <<
"(" << Num*100ULL/Sum <<
"."
328 << ((Num*1000ULL/Sum) % 10) <<
"%)\n";
331 bool AAEval::doFinalization(
Module &M) {
332 unsigned AliasSum = NoAlias + MayAlias + PartialAlias + MustAlias;
333 errs() <<
"===== Alias Analysis Evaluator Report =====\n";
335 errs() <<
" Alias Analysis Evaluator Summary: No pointers!\n";
337 errs() <<
" " << AliasSum <<
" Total Alias Queries Performed\n";
338 errs() <<
" " << NoAlias <<
" no alias responses ";
340 errs() <<
" " << MayAlias <<
" may alias responses ";
342 errs() <<
" " << PartialAlias <<
" partial alias responses ";
344 errs() <<
" " << MustAlias <<
" must alias responses ";
346 errs() <<
" Alias Analysis Evaluator Pointer Alias Summary: "
347 << NoAlias*100/AliasSum <<
"%/" << MayAlias*100/AliasSum <<
"%/"
348 << PartialAlias*100/AliasSum <<
"%/"
349 << MustAlias*100/AliasSum <<
"%\n";
353 unsigned ModRefSum = NoModRef + Mod + Ref + ModRef;
354 if (ModRefSum == 0) {
355 errs() <<
" Alias Analysis Mod/Ref Evaluator Summary: no mod/ref!\n";
357 errs() <<
" " << ModRefSum <<
" Total ModRef Queries Performed\n";
358 errs() <<
" " << NoModRef <<
" no mod/ref responses ";
360 errs() <<
" " << Mod <<
" mod responses ";
362 errs() <<
" " << Ref <<
" ref responses ";
364 errs() <<
" " << ModRef <<
" mod & ref responses ";
366 errs() <<
" Alias Analysis Evaluator Mod/Ref Summary: "
367 << NoModRef*100/ModRefSum <<
"%/" << Mod*100/ModRefSum <<
"%/"
368 << Ref*100/ModRefSum <<
"%/" << ModRef*100/ModRefSum <<
"%\n";
static cl::opt< bool > PrintPartialAlias("print-partial-aliases", cl::ReallyHidden)
Pointers differ, but pointees overlap.
static PassRegistry * getPassRegistry()
size_t size() const
size - Get the string size.
ModRefResult getModRefInfo(const Instruction *I, const Location &Loc)
The main container class for the LLVM Intermediate Representation.
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)
FunctionPass * createAAEvalPass()
static cl::opt< bool > EvalTBAA("evaluate-tbaa", cl::ReallyHidden)
iterator end()
Get an iterator to the end of the SetVector.
size_type size() const
Determine the number of elements in the SetVector.
aa Exhaustive Alias Analysis Precision false
static cl::opt< bool > PrintMustAlias("print-must-aliases", cl::ReallyHidden)
StringRef getName() const
void WriteAsOperand(raw_ostream &, const Value *, bool PrintTy=true, const Module *Context=0)
AnalysisUsage & addRequired()
inst_iterator inst_begin(Function *F)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
ID
LLVM Calling Convention Representation.
bool insert(const value_type &X)
Insert a new element into the SetVector.
iterator begin()
Get an iterator to the beginning of the SetVector.
uint64_t getTypeStoreSize(Type *Ty)
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)
User::op_iterator arg_iterator
InstrTy * getInstruction() const
virtual AliasResult alias(const Location &LocA, const Location &LocB)
static cl::opt< bool > PrintMayAlias("print-may-aliases", cl::ReallyHidden)
#define INITIALIZE_AG_DEPENDENCY(depName)
void initializeAAEvalPass(PassRegistry &)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Location getLocation(const LoadInst *LI)
block Block Frequency Analysis
INITIALIZE_PASS_BEGIN(AAEval,"aa-eval","Exhaustive Alias Analysis Precision Evaluator", false, true) INITIALIZE_PASS_END(AAEval
static uint64_t const UnknownSize
static cl::opt< bool > PrintNoModRef("print-no-modref", cl::ReallyHidden)
LLVM Value Representation.
vector_type::const_iterator iterator
A vector that has set insertion semantics.
static void PrintPercent(unsigned Num, unsigned Sum)
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)