36 std::pair<const Value *, Type *> Loc1,
37 std::pair<const Value *, Type *> Loc2,
40 Type *Ty1 = Loc1.second, *Ty2 = Loc2.second;
42 unsigned AS2 = Loc2.first->getType()->getPointerAddressSpace();
46 Loc1.first->printAsOperand(os1,
false, M);
47 Loc2.first->printAsOperand(os2,
false, M);
57 errs() <<
" " << AR <<
":\t";
60 errs() <<
" addrspace(" << AS1 <<
")";
61 errs() <<
"* " << o1 <<
", ";
62 Ty2->print(
errs(),
false,
true);
64 errs() <<
" addrspace(" << AS2 <<
")";
65 errs() <<
"* " << o2 <<
"\n";
71 std::pair<const Value *, Type *> Loc,
Module *M) {
73 errs() <<
" " << Msg <<
": Ptr: ";
74 Loc.second->print(
errs(),
false,
true);
76 Loc.first->printAsOperand(
errs(),
false, M);
77 errs() <<
"\t<->" << *
I <<
'\n';
84 errs() <<
" " << Msg <<
": " << *CallA <<
" <-> " << *CallB <<
'\n';
92 errs() <<
" " << AR <<
": " << *V1 <<
" <-> " << *V2 <<
'\n';
112 if (
auto *LI = dyn_cast<LoadInst>(&Inst)) {
113 Pointers.
insert({LI->getPointerOperand(), LI->getType()});
115 }
else if (
auto *SI = dyn_cast<StoreInst>(&Inst)) {
116 Pointers.
insert({
SI->getPointerOperand(),
117 SI->getValueOperand()->getType()});
119 }
else if (
auto *CB = dyn_cast<CallBase>(&Inst))
125 errs() <<
"Function: " <<
F.getName() <<
": " << Pointers.
size()
126 <<
" pointers, " << Calls.
size() <<
" call sites\n";
129 for (
auto I1 = Pointers.
begin(), E = Pointers.
end(); I1 != E; ++I1) {
131 for (
auto I2 = Pointers.
begin(); I2 != I1; ++I2) {
158 for (
Value *Load : Loads) {
159 for (
Value *Store : Stores) {
213 for (
const auto &Pointer : Pointers) {
269 errs() <<
"(" << Num * 100LL / Sum <<
"." << ((Num * 1000LL / Sum) % 10)
274 if (FunctionCount == 0)
278 NoAliasCount + MayAliasCount + PartialAliasCount + MustAliasCount;
279 errs() <<
"===== Alias Analysis Evaluator Report =====\n";
281 errs() <<
" Alias Analysis Evaluator Summary: No pointers!\n";
283 errs() <<
" " << AliasSum <<
" Total Alias Queries Performed\n";
284 errs() <<
" " << NoAliasCount <<
" no alias responses ";
286 errs() <<
" " << MayAliasCount <<
" may alias responses ";
288 errs() <<
" " << PartialAliasCount <<
" partial alias responses ";
290 errs() <<
" " << MustAliasCount <<
" must alias responses ";
292 errs() <<
" Alias Analysis Evaluator Pointer Alias Summary: "
293 << NoAliasCount * 100 / AliasSum <<
"%/"
294 << MayAliasCount * 100 / AliasSum <<
"%/"
295 << PartialAliasCount * 100 / AliasSum <<
"%/"
296 << MustAliasCount * 100 / AliasSum <<
"%\n";
300 int64_t ModRefSum = NoModRefCount + RefCount + ModCount + ModRefCount;
301 if (ModRefSum == 0) {
302 errs() <<
" Alias Analysis Mod/Ref Evaluator Summary: no "
305 errs() <<
" " << ModRefSum <<
" Total ModRef Queries Performed\n";
306 errs() <<
" " << NoModRefCount <<
" no mod/ref responses ";
308 errs() <<
" " << ModCount <<
" mod responses ";
310 errs() <<
" " << RefCount <<
" ref responses ";
312 errs() <<
" " << ModRefCount <<
" mod & ref responses ";
314 errs() <<
" Alias Analysis Evaluator Mod/Ref Summary: "
315 << NoModRefCount * 100 / ModRefSum <<
"%/"
316 << ModCount * 100 / ModRefSum <<
"%/" << RefCount * 100 / ModRefSum
317 <<
"%/" << ModRefCount * 100 / ModRefSum <<
"%\n";
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static void PrintModRefResults(const char *Msg, bool P, Instruction *I, std::pair< const Value *, Type * > Loc, Module *M)
static cl::opt< bool > PrintModRef("print-modref", cl::ReallyHidden)
static void PrintLoadStoreResults(AliasResult AR, bool P, const Value *V1, const Value *V2, const Module *M)
static void PrintPercent(int64_t Num, int64_t Sum)
static cl::opt< bool > EvalAAMD("evaluate-aa-metadata", cl::ReallyHidden)
static cl::opt< bool > PrintRef("print-ref", cl::ReallyHidden)
static cl::opt< bool > PrintNoAlias("print-no-aliases", cl::ReallyHidden)
static cl::opt< bool > PrintMayAlias("print-may-aliases", cl::ReallyHidden)
static cl::opt< bool > PrintMod("print-mod", cl::ReallyHidden)
static cl::opt< bool > PrintMustAlias("print-must-aliases", cl::ReallyHidden)
static cl::opt< bool > PrintAll("print-all-alias-modref-info", cl::ReallyHidden)
static cl::opt< bool > PrintNoModRef("print-no-modref", cl::ReallyHidden)
static cl::opt< bool > PrintPartialAlias("print-partial-aliases", cl::ReallyHidden)
This file implements a simple N^2 alias analysis accuracy evaluator.
static cl::opt< bool > PrintResults("print-debug-ata", cl::init(false), cl::Hidden)
Print the results of the analysis. Respects -filter-print-funcs.
Expand Atomic instructions
Module.h This file contains the declarations for the Module class.
This file implements a set that has insertion order iteration characteristics.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
A manager for alias analyses.
ModRefInfo getModRefInfo(const Instruction *I, const std::optional< MemoryLocation > &OptLoc)
Check whether or not an instruction may read or write the optionally specified memory location.
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
The main low level interface to the alias analysis implementation.
The possible results of an alias query.
void swap(bool DoSwap=true)
Helper for processing AliasResult for swapped memory location pairs.
@ MayAlias
The two locations may or may not alias.
@ NoAlias
The two locations do not alias at all.
@ PartialAlias
The two locations alias, but only due to a partial overlap.
@ MustAlias
The two locations precisely alias each other.
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
A parsed version of the target data layout string in and methods for querying it.
static LocationSize precise(uint64_t Value)
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
A vector that has set insertion semantics.
size_type size() const
Determine the number of elements in the SetVector.
typename vector_type::const_iterator iterator
iterator end()
Get an iterator to the end of the SetVector.
iterator begin()
Get an iterator to the beginning of the SetVector.
bool insert(const value_type &X)
Insert a new element into the SetVector.
A SetVector that performs no allocations if smaller than a certain size.
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
void print(raw_ostream &O, bool IsForDebug=false, bool NoDetails=false) const
Print the current type.
LLVM Value Representation.
A raw_ostream that writes to an std::string.
This is an optimization pass for GlobalISel generic memory operations.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
@ Ref
The access may reference the value stored in memory.
@ ModRef
The access may reference and may modify the value stored in memory.
@ Mod
The access may modify the value stored in memory.
@ NoModRef
The access neither references nor modifies the value stored in memory.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.