32 unsigned No, May, Partial, Must;
33 unsigned NoMR, JustRef, JustMod, MR;
39 No = May = Partial = Must = 0;
40 NoMR = JustRef = JustMod = MR = 0;
43 void printLine(
const char *Desc,
unsigned Val,
unsigned Sum) {
44 errs() <<
" " << Val <<
" " << Desc <<
" responses ("
45 << Val*100/Sum <<
"%)\n";
47 ~AliasAnalysisCounter()
override {
48 unsigned AASum = No+May+Partial+Must;
49 unsigned MRSum = NoMR+JustRef+JustMod+MR;
51 errs() <<
"\n===== Alias Analysis Counter Report =====\n"
52 <<
" Analysis counted:\n"
53 <<
" " << AASum <<
" Total Alias Queries Performed\n";
57 printLine(
"partial alias", Partial, AASum);
59 errs() <<
" Alias Analysis Counter Summary: " << No*100/AASum <<
"%/"
60 << May*100/AASum <<
"%/"
61 << Partial*100/AASum <<
"%/"
62 << Must*100/AASum<<
"%\n\n";
65 errs() <<
" " << MRSum <<
" Total Mod/Ref Queries Performed\n";
71 errs() <<
" Mod/Ref Analysis Counter Summary: " <<NoMR*100/MRSum
72 <<
"%/" << JustRef*100/MRSum <<
"%/" << JustMod*100/MRSum
73 <<
"%/" << MR*100/MRSum <<
"%\n\n";
78 bool runOnModule(
Module &M)
override {
94 void *getAdjustedAnalysisPointer(
AnalysisID PI)
override {
102 bool OrLocal)
override {
103 return getAnalysis<AliasAnalysis>().pointsToConstantMemory(Loc, OrLocal);
122 "Count Alias Analysis Query Responses",
false,
true,
false)
125 return new AliasAnalysisCounter();
130 AliasResult R = getAnalysis<AliasAnalysis>().alias(LocA, LocB);
132 const char *AliasString =
nullptr;
134 case NoAlias: No++; AliasString =
"No alias";
break;
135 case MayAlias: May++; AliasString =
"May alias";
break;
136 case PartialAlias: Partial++; AliasString =
"Partial alias";
break;
137 case MustAlias: Must++; AliasString =
"Must alias";
break;
141 errs() << AliasString <<
":\t";
142 errs() <<
"[" << LocA.
Size <<
"B] ";
145 errs() <<
"[" << LocB.
Size <<
"B] ";
156 ModRefResult R = getAnalysis<AliasAnalysis>().getModRefInfo(CS, Loc);
158 const char *MRString =
nullptr;
160 case NoModRef: NoMR++; MRString =
"NoModRef";
break;
161 case Ref: JustRef++; MRString =
"JustRef";
break;
162 case Mod: JustMod++; MRString =
"JustMod";
break;
163 case ModRef: MR++; MRString =
"ModRef";
break;
167 errs() << MRString <<
": Ptr: ";
The two locations precisely alias each other.
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...
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.
The two locations do not alias at all.
The two locations may or may not alias. This is the least precise result.
AnalysisUsage & addRequired()
INITIALIZE_AG_PASS(AliasAnalysisCounter, AliasAnalysis,"count-aa","Count Alias Analysis Query Responses", false, true, false) ModulePass *llvm
ModulePass * createAliasAnalysisCounterPass()
void initializeAliasAnalysisCounterPass(PassRegistry &)
static cl::opt< bool > PrintAllFailures("count-aa-print-all-failed-queries", cl::ReallyHidden)
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.
initializer< Ty > init(const Ty &Val)
AliasResult
The possible results of an alias query.
Represent the analysis usage information of a pass.
static cl::opt< bool > PrintAll("count-aa-print-all-queries", cl::ReallyHidden, cl::init(true))
const Value * Ptr
The address of the start of the location.
Representation for a specific memory location.
static void printLine(raw_ostream &OS, const Twine &Prefix, char Fill, StringRef Suffix)
Module.h This file contains the declarations for the Module class.
ModRefResult getModRefInfo(const Instruction *I)
getModRefInfo - Return information about whether or not an instruction may read or write memory (with...
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.
ImmutableCallSite - establish a view to a call site for examination.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
ModRefResult
Simple mod/ref information...
virtual void getAnalysisUsage(AnalysisUsage &AU) const
getAnalysisUsage - All alias analysis implementations should invoke this directly (using AliasAnalysi...
uint64_t Size
The maximum size of the location, in address-units, or UnknownSize if the size is not known...