Go to the documentation of this file.
42 std::pair<const Value *, Type *> Loc1,
43 std::pair<const Value *, Type *> Loc2,
46 Type *Ty1 = Loc1.second, *Ty2 = Loc2.second;
48 unsigned AS2 = Loc2.first->getType()->getPointerAddressSpace();
52 Loc1.first->printAsOperand(os1,
false,
M);
53 Loc2.first->printAsOperand(os2,
false,
M);
63 errs() <<
" " << AR <<
":\t";
66 errs() <<
" addrspace(" << AS1 <<
")";
67 errs() <<
"* " << o1 <<
", ";
68 Ty2->print(
errs(),
false,
true);
70 errs() <<
" addrspace(" << AS2 <<
")";
71 errs() <<
"* " << o2 <<
"\n";
77 std::pair<const Value *, Type *> Loc,
Module *M) {
79 errs() <<
" " <<
Msg <<
": Ptr: ";
80 Loc.second->print(
errs(),
false,
true);
82 Loc.first->printAsOperand(
errs(),
false,
M);
83 errs() <<
"\t<->" << *
I <<
'\n';
90 errs() <<
" " <<
Msg <<
": " << *CallA <<
" <-> " << *CallB <<
'\n';
98 errs() <<
" " << AR <<
": " << *V1 <<
" <-> " << *
V2 <<
'\n';
118 if (
auto *LI = dyn_cast<LoadInst>(&Inst)) {
119 Pointers.
insert({LI->getPointerOperand(), LI->getType()});
121 }
else if (
auto *
SI = dyn_cast<StoreInst>(&Inst)) {
122 Pointers.
insert({
SI->getPointerOperand(),
123 SI->getValueOperand()->getType()});
125 }
else if (
auto *CB = dyn_cast<CallBase>(&Inst))
131 errs() <<
"Function: " <<
F.getName() <<
": " << Pointers.
size()
132 <<
" pointers, " << Calls.
size() <<
" call sites\n";
137 for (
auto I2 = Pointers.
begin(); I2 !=
I1; ++I2) {
219 for (
const auto &Pointer : Pointers) {
222 switch (
AA.getModRefInfo(Call,
Pointer.first, Size)) {
257 Pointer,
F.getParent());
269 switch (
AA.getModRefInfo(CallA, CallB)) {
304 CallB,
F.getParent());
313 errs() <<
"(" << Num * 100LL / Sum <<
"." << ((Num * 1000LL / Sum) % 10)
318 if (FunctionCount == 0)
322 NoAliasCount + MayAliasCount + PartialAliasCount + MustAliasCount;
323 errs() <<
"===== Alias Analysis Evaluator Report =====\n";
325 errs() <<
" Alias Analysis Evaluator Summary: No pointers!\n";
327 errs() <<
" " << AliasSum <<
" Total Alias Queries Performed\n";
328 errs() <<
" " << NoAliasCount <<
" no alias responses ";
330 errs() <<
" " << MayAliasCount <<
" may alias responses ";
332 errs() <<
" " << PartialAliasCount <<
" partial alias responses ";
334 errs() <<
" " << MustAliasCount <<
" must alias responses ";
336 errs() <<
" Alias Analysis Evaluator Pointer Alias Summary: "
337 << NoAliasCount * 100 / AliasSum <<
"%/"
338 << MayAliasCount * 100 / AliasSum <<
"%/"
339 << PartialAliasCount * 100 / AliasSum <<
"%/"
340 << MustAliasCount * 100 / AliasSum <<
"%\n";
344 int64_t ModRefSum = NoModRefCount + RefCount + ModCount + ModRefCount +
345 MustCount + MustRefCount + MustModCount + MustModRefCount;
346 if (ModRefSum == 0) {
347 errs() <<
" Alias Analysis Mod/Ref Evaluator Summary: no "
350 errs() <<
" " << ModRefSum <<
" Total ModRef Queries Performed\n";
351 errs() <<
" " << NoModRefCount <<
" no mod/ref responses ";
353 errs() <<
" " << ModCount <<
" mod responses ";
355 errs() <<
" " << RefCount <<
" ref responses ";
357 errs() <<
" " << ModRefCount <<
" mod & ref responses ";
359 errs() <<
" " << MustCount <<
" must responses ";
361 errs() <<
" " << MustModCount <<
" must mod responses ";
363 errs() <<
" " << MustRefCount <<
" must ref responses ";
365 errs() <<
" " << MustModRefCount <<
" must mod & ref responses ";
367 errs() <<
" Alias Analysis Evaluator Mod/Ref Summary: "
368 << NoModRefCount * 100 / ModRefSum <<
"%/"
369 << ModCount * 100 / ModRefSum <<
"%/" << RefCount * 100 / ModRefSum
370 <<
"%/" << ModRefCount * 100 / ModRefSum <<
"%/"
371 << MustCount * 100 / ModRefSum <<
"%/"
372 << MustRefCount * 100 / ModRefSum <<
"%/"
373 << MustModCount * 100 / ModRefSum <<
"%/"
374 << MustModRefCount * 100 / ModRefSum <<
"%\n";
380 std::unique_ptr<AAEvaluator> P;
399 P->runInternal(
F, getAnalysis<AAResultsWrapperPass>().getAAResults());
411 "Exhaustive Alias Analysis Precision Evaluator",
false,
A set of analyses that are preserved following a run of a transformation pass.
@ NoModRef
The access neither references nor modifies the value stored in memory.
A manager for alias analyses.
@ MayAlias
The two locations may or may not alias.
@ PartialAlias
The two locations alias, but only due to a partial overlap.
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
A parsed version of the target data layout string in and methods for querying it.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
A raw_ostream that writes to an std::string.
size_type size() const
Determine the number of elements in the SetVector.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
The instances of the Type class are immutable: once they are created, they are never changed.
The possible results of an alias query.
static cl::opt< bool > PrintMust("print-must", cl::ReallyHidden)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
static void PrintPercent(int64_t Num, int64_t Sum)
static void PrintLoadStoreResults(AliasResult AR, bool P, const Value *V1, const Value *V2, const Module *M)
@ Must
Must is provided for completeness, but no routines will return only Must today.
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
static cl::opt< bool > PrintMustMod("print-mustmod", cl::ReallyHidden)
@ MustRef
The access may reference the value stored in memory, a mustAlias relation was found,...
FunctionPass * createAAEvalPass()
Create a wrapper of the above for the legacy pass manager.
iterator begin()
Get an iterator to the beginning of the SetVector.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
@ Ref
The access may reference the value stored in memory.
static cl::opt< bool > PrintNoModRef("print-no-modref", cl::ReallyHidden)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
@ MustModRef
The access may reference, modify or both the value stored in memory, a mustAlias relation was found,...
@ MustMod
The access may modify the value stored in memory, a mustAlias relation was found, and no mayAlias or ...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
static cl::opt< bool > EvalAAMD("evaluate-aa-metadata", cl::ReallyHidden)
void print(raw_ostream &O, bool IsForDebug=false, bool NoDetails=false) const
Print the current type.
Represent the analysis usage information of a pass.
static cl::opt< bool > PrintMustRef("print-mustref", cl::ReallyHidden)
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
static LocationSize precise(uint64_t Value)
void initializeAAEvalLegacyPassPass(PassRegistry &)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
static cl::opt< bool > PrintPartialAlias("print-partial-aliases", cl::ReallyHidden)
static cl::opt< bool > PrintAll("print-all-alias-modref-info", cl::ReallyHidden)
static cl::opt< bool > PrintNoAlias("print-no-aliases", cl::ReallyHidden)
static cl::opt< bool > PrintMustModRef("print-mustmodref", cl::ReallyHidden)
inst_range instructions(Function *F)
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
This class evaluates LLVM IR, producing the Constant representing each SSA instruction.
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
static cl::opt< bool > PrintMod("print-mod", cl::ReallyHidden)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
StandardInstrumentations SI(Debug, VerifyEach)
static cl::opt< bool > PrintModRef("print-modref", cl::ReallyHidden)
A Module instance is used to store all the information related to an LLVM module.
bool insert(const value_type &X)
Insert a new element into the SetVector.
void swap(bool DoSwap=true)
Helper for processing AliasResult for swapped memory location pairs.
@ NoAlias
The two locations do not alias at all.
@ Mod
The access may modify the value stored in memory.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
@ MustAlias
The two locations precisely alias each other.
const CustomOperand< const MCSubtargetInfo & > Msg[]
static cl::opt< bool > PrintMustAlias("print-must-aliases", cl::ReallyHidden)
void setPreservesAll()
Set by analyses that do not transform their input at all.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static void PrintResults(AliasResult AR, bool P, std::pair< const Value *, Type * > Loc1, std::pair< const Value *, Type * > Loc2, const Module *M)
iterator end()
Get an iterator to the end of the SetVector.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
static cl::opt< bool > PrintRef("print-ref", cl::ReallyHidden)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
A SetVector that performs no allocations if smaller than a certain size.
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
INITIALIZE_PASS_BEGIN(AAEvalLegacyPass, "aa-eval", "Exhaustive Alias Analysis Precision Evaluator", false, true) INITIALIZE_PASS_END(AAEvalLegacyPass
AnalysisUsage & addRequired()
static void PrintModRefResults(const char *Msg, bool P, Instruction *I, std::pair< const Value *, Type * > Loc, Module *M)
static cl::opt< bool > PrintMayAlias("print-may-aliases", cl::ReallyHidden)
A vector that has set insertion semantics.
LLVM Value Representation.
@ ModRef
The access may reference and may modify the value stored in memory.