34 static const char *
const DepTypeStr[];
37 typedef std::pair<InstTypePair, const BasicBlock *> Dep;
57 void releaseMemory()
override {
65 return InstTypePair(dep.
getInst(), Clobber);
69 return InstTypePair(dep.
getInst(), NonFuncLocal);
73 static InstTypePair getInstTypePair(
const Instruction* inst, DepType type) {
74 return InstTypePair(inst, type);
81 "Print MemDeps of function",
false,
true)
87 return new MemDepPrinter();
90 const char *
const MemDepPrinter::DepTypeStr[]
91 = {
"Clobber",
"Def",
"NonFuncLocal",
"Unknown"};
93 bool MemDepPrinter::runOnFunction(
Function &
F) {
107 Deps[Inst].insert(std::make_pair(getInstTypePair(Res),
108 static_cast<BasicBlock *>(
nullptr)));
109 }
else if (
auto CS =
CallSite(Inst)) {
113 DepSet &InstDeps = Deps[Inst];
116 InstDeps.insert(std::make_pair(getInstTypePair(Res),
I.getBB()));
120 assert( (isa<LoadInst>(Inst) || isa<StoreInst>(Inst) ||
121 isa<VAArgInst>(Inst)) &&
"Unknown memory instruction!");
124 DepSet &InstDeps = Deps[Inst];
127 InstDeps.insert(std::make_pair(getInstTypePair(Res),
I.getBB()));
139 DepSetMap::const_iterator
DI = Deps.find(Inst);
140 if (DI == Deps.end())
143 const DepSet &InstDeps = DI->second;
145 for (
const auto &
I : InstDeps) {
147 DepType type =
I.first.getInt();
151 OS << DepTypeStr[type];
Provides a lazy, caching interface for making common memory aliasing information queries, backed by LLVM's alias analysis passes.
void initializeMemDepPrinterPass(PassRegistry &)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
void Print(const Unit &v, const char *PrintAfter)
bool isDef() const
Tests if this MemDepResult represents a query that is an instruction definition dependency.
A Module instance is used to store all the information related to an LLVM module. ...
bool isUnknown() const
Tests if this MemDepResult represents a query which cannot and/or will not be computed.
bool isClobber() const
Tests if this MemDepResult represents a query that is an instruction clobber dependency.
INITIALIZE_PASS_BEGIN(MemDepPrinter,"print-memdeps","Print MemDeps of function", false, true) INITIALIZE_PASS_END(MemDepPrinter
#define INITIALIZE_PASS_DEPENDENCY(depName)
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
void getNonLocalPointerDependency(Instruction *QueryInst, SmallVectorImpl< NonLocalDepResult > &Result)
Perform a full dependency query for an access to the QueryInst's specified memory location...
std::vector< NonLocalDepEntry > NonLocalDepInfo
bool mayReadFromMemory() const
Return true if this instruction may read memory.
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.
const NonLocalDepInfo & getNonLocalCallDependency(CallSite QueryCS)
Perform a full dependency query for the specified call, returning the set of blocks that the value is...
FunctionPass * createMemDepPrinter()
LLVM Basic Block Representation.
PointerIntPair - This class implements a pair of a pointer and small integer.
This is a result from a NonLocal dependence query.
print Print MemDeps of false
Represent the analysis usage information of a pass.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
FunctionPass class - This class is used to implement most global optimizations.
A wrapper analysis pass for the legacy pass manager that exposes a MemoryDepnedenceResults instance...
bool mayWriteToMemory() const
Return true if this instruction may modify memory.
A memory dependence query can return one of three different answers.
A SetVector that performs no allocations if smaller than a certain size.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool isNonLocal() const
Tests if this MemDepResult represents a query that is transparent to the start of the block...
void setPreservesAll()
Set by analyses that do not transform their input at all.
Instruction * getInst() const
If this is a normal dependency, returns the instruction that is depended on.
AnalysisUsage & addRequiredTransitive()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
print Print MemDeps of function
inst_range instructions(Function *F)
This is an entry in the NonLocalDepInfo cache.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
bool isNonFuncLocal() const
Tests if this MemDepResult represents a query that is transparent to the start of the function...
MemDepResult getDependency(Instruction *QueryInst)
Returns the instruction on which a memory operation depends.