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);
70 assert(dep.
isUnknown() &&
"unexpected dependence type");
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];
114 for (MemoryDependenceAnalysis::NonLocalDepInfo::const_iterator
115 I = NLDI.begin(), E = NLDI.end();
I != E; ++
I) {
117 InstDeps.insert(std::make_pair(getInstTypePair(Res),
I->getBB()));
121 assert( (isa<LoadInst>(Inst) || isa<StoreInst>(Inst) ||
122 isa<VAArgInst>(Inst)) &&
"Unknown memory instruction!");
125 DepSet &InstDeps = Deps[Inst];
129 InstDeps.insert(std::make_pair(getInstTypePair(Res),
I->getBB()));
141 DepSetMap::const_iterator
DI = Deps.find(Inst);
142 if (DI == Deps.end())
145 const DepSet &InstDeps = DI->second;
147 for (
const auto &
I : InstDeps) {
149 DepType type =
I.first.getInt();
153 OS << DepTypeStr[type];
void initializeMemDepPrinterPass(PassRegistry &)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
bool isDef() const
isDef - Return true if this MemDepResult represents a query that is an instruction definition depende...
A Module instance is used to store all the information related to an LLVM module. ...
void Print(const Unit &U, const char *PrintAfter="")
bool isUnknown() const
isUnknown - Return true if this MemDepResult represents a query which cannot and/or will not be compu...
bool isClobber() const
isClobber - Return true if this MemDepResult represents a query that is an instruction clobber depend...
INITIALIZE_PASS_BEGIN(MemDepPrinter,"print-memdeps","Print MemDeps of function", false, true) INITIALIZE_PASS_END(MemDepPrinter
#define INITIALIZE_PASS_DEPENDENCY(depName)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
MemoryDependenceAnalysis - This is an analysis that determines, for a given memory operation...
void print(raw_ostream &O) const
Implement operator<< on Value.
bool mayReadFromMemory() const
mayReadFromMemory - 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.
FunctionPass * createMemDepPrinter()
LLVM Basic Block Representation.
PointerIntPair - This class implements a pair of a pointer and small integer.
print Print MemDeps of false
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
bool mayWriteToMemory() const
mayWriteToMemory - Return true if this instruction may modify memory.
MemDepResult - A memory dependence query can return one of three different answers, described below.
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
isNonLocal - Return true if this MemDepResult represents a query that is transparent to the start of ...
std::vector< NonLocalDepEntry > NonLocalDepInfo
void setPreservesAll()
Set by analyses that do not transform their input at all.
Instruction * getInst() const
getInst() - If this is a normal dependency, return the instruction that is depended on...
MemDepResult getDependency(Instruction *QueryInst)
getDependency - Return the instruction on which a memory operation depends.
iterator_range< inst_iterator > inst_range(Function *F)
const NonLocalDepInfo & getNonLocalCallDependency(CallSite QueryCS)
getNonLocalCallDependency - Perform a full dependency query for the specified call, returning the set of blocks that the value is potentially live across.
AnalysisUsage & addRequiredTransitive()
This class implements an extremely fast bulk output stream that can only output to a stream...
print Print MemDeps of function
bool isNonFuncLocal() const
isNonFuncLocal - Return true if this MemDepResult represents a query that is transparent to the start...
void getNonLocalPointerDependency(Instruction *QueryInst, SmallVectorImpl< NonLocalDepResult > &Result)
getNonLocalPointerDependency - Perform a full dependency query for an access to the QueryInst's speci...