22 std::pair<const Value *, Type *> Loc1,
23 std::pair<const Value *, Type *> Loc2,
25 if (Opts.print_all_alias_modref_info ||
P) {
26 Type *Ty1 = Loc1.second, *Ty2 = Loc2.second;
27 unsigned AS1 = Loc1.first->getType()->getPointerAddressSpace();
28 unsigned AS2 = Loc2.first->getType()->getPointerAddressSpace();
32 Loc1.first->printAsOperand(os1,
false, M);
33 Loc2.first->printAsOperand(os2,
false, M);
43 errs() <<
" " << AR <<
":\t";
46 errs() <<
" addrspace(" << AS1 <<
")";
47 errs() <<
"* " << o1 <<
", ";
48 Ty2->print(
errs(),
false,
true);
50 errs() <<
" addrspace(" << AS2 <<
")";
51 errs() <<
"* " << o2 <<
"\n";
57 std::pair<const Value *, Type *>
Loc,
59 if (Opts.print_all_alias_modref_info ||
P) {
60 errs() <<
" " <<
Msg <<
": Ptr: ";
61 Loc.second->print(
errs(),
false,
true);
63 Loc.first->printAsOperand(
errs(),
false, M);
64 errs() <<
"\t<->" << *
I <<
'\n';
69 const char *
Msg,
bool P,
72 if (Opts.print_all_alias_modref_info ||
P) {
73 errs() <<
" " <<
Msg <<
": " << *MemOpA <<
" <-> " << *MemOpB <<
'\n';
81 if (Opts.print_all_alias_modref_info ||
P) {
82 errs() <<
" " << AR <<
": " << *
V1 <<
" <-> " << *V2 <<
'\n';
104 Pointers.
insert({LI->getPointerOperand(), LI->getType()});
107 Pointers.
insert({
SI->getPointerOperand(),
108 SI->getValueOperand()->getType()});
113 OtherMemOps.
insert(&Inst);
116 if (Opts.print_all_alias_modref_info || Opts.print_no_aliases ||
117 Opts.print_may_aliases || Opts.print_partial_aliases ||
118 Opts.print_must_aliases || Opts.print_no_modref || Opts.print_mod ||
119 Opts.print_ref || Opts.print_modref)
120 errs() <<
"Function: " <<
F.getName() <<
": " << Pointers.
size()
121 <<
" pointers, " << OtherMemOps.
size() <<
" call sites\n";
124 for (
auto I1 = Pointers.
begin(),
E = Pointers.
end(); I1 !=
E; ++I1) {
126 for (
auto I2 = Pointers.
begin(); I2 != I1; ++I2) {
129 AliasResult AR = AA.
alias(
I1->first, Size1, I2->first, Size2);
132 printResults(Opts, AR, Opts.print_no_aliases, *I1, *I2,
F.getParent());
136 printResults(Opts, AR, Opts.print_may_aliases, *I1, *I2,
F.getParent());
140 printResults(Opts, AR, Opts.print_partial_aliases, *I1, *I2,
145 printResults(Opts, AR, Opts.print_must_aliases, *I1, *I2,
153 if (Opts.evaluate_aa_metadata) {
217 for (Instruction *MemOp : OtherMemOps) {
218 for (
const auto &Pointer : Pointers) {
224 Pointer,
F.getParent());
239 Pointer,
F.getParent());
247 for (Instruction *MemOpA : OtherMemOps) {
248 for (Instruction *MemOpB : OtherMemOps) {
249 if (MemOpA == MemOpB)
254 MemOpB,
F.getParent());
269 MemOpB,
F.getParent());
278 errs() <<
"(" << Num * 100LL / Sum <<
"." << ((Num * 1000LL / Sum) % 10)
283 if (FunctionCount == 0)
287 NoAliasCount + MayAliasCount + PartialAliasCount + MustAliasCount;
288 errs() <<
"===== Alias Analysis Evaluator Report =====\n";
290 errs() <<
" Alias Analysis Evaluator Summary: No pointers!\n";
292 errs() <<
" " << AliasSum <<
" Total Alias Queries Performed\n";
293 errs() <<
" " << NoAliasCount <<
" no alias responses ";
295 errs() <<
" " << MayAliasCount <<
" may alias responses ";
297 errs() <<
" " << PartialAliasCount <<
" partial alias responses ";
299 errs() <<
" " << MustAliasCount <<
" must alias responses ";
301 errs() <<
" Alias Analysis Evaluator Pointer Alias Summary: "
302 << NoAliasCount * 100 / AliasSum <<
"%/"
303 << MayAliasCount * 100 / AliasSum <<
"%/"
304 << PartialAliasCount * 100 / AliasSum <<
"%/"
305 << MustAliasCount * 100 / AliasSum <<
"%\n";
309 int64_t ModRefSum = NoModRefCount + RefCount + ModCount + ModRefCount;
310 if (ModRefSum == 0) {
311 errs() <<
" Alias Analysis Mod/Ref Evaluator Summary: no "
314 errs() <<
" " << ModRefSum <<
" Total ModRef Queries Performed\n";
315 errs() <<
" " << NoModRefCount <<
" no mod/ref responses ";
317 errs() <<
" " << ModCount <<
" mod responses ";
319 errs() <<
" " << RefCount <<
" ref responses ";
321 errs() <<
" " << ModRefCount <<
" mod & ref responses ";
323 errs() <<
" Alias Analysis Evaluator Mod/Ref Summary: "
324 << NoModRefCount * 100 / ModRefSum <<
"%/"
325 << ModCount * 100 / ModRefSum <<
"%/" << RefCount * 100 / ModRefSum
326 <<
"%/" << ModRefCount * 100 / ModRefSum <<
"%\n";
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static void printResults(const AnalysisOptions &Opts, AliasResult AR, bool P, std::pair< const Value *, Type * > Loc1, std::pair< const Value *, Type * > Loc2, const Module *M)
static void PrintPercent(int64_t Num, int64_t Sum)
static void printModRefResults(const AnalysisOptions &Opts, const char *Msg, bool P, Instruction *I, std::pair< const Value *, Type * > Loc, Module *M)
static void printLoadStoreResults(const AnalysisOptions &Opts, AliasResult AR, bool P, const Value *V1, const Value *V2, const Module *M)
This file implements a simple N^2 alias analysis accuracy evaluator.
Expand Atomic instructions
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Module.h This file contains the declarations for the Module class.
This file implements a set that has insertion order iteration characteristics.
LLVM_ABI 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.
LLVM_ABI 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.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
A parsed version of the target data layout string in and methods for querying it.
static LocationSize precise(uint64_t Value)
static LLVM_ABI 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.
LLVM_ABI 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.
Abstract Attribute helper functions.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
const AnalysisOptions & getAnalysisOptions(const LLVMContext &C)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI 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.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.