35 static const char *
const DepTypeStr[];
38 typedef std::pair<InstTypePair, const BasicBlock *> Dep;
58 virtual void releaseMemory() {
66 return InstTypePair(dep.
getInst(), Clobber);
70 return InstTypePair(dep.
getInst(), NonFuncLocal);
71 assert(dep.
isUnknown() &&
"unexptected dependence type");
74 static InstTypePair getInstTypePair(
const Instruction* inst, DepType type) {
75 return InstTypePair(inst, type);
82 "Print MemDeps of function",
false,
true)
88 return new MemDepPrinter();
91 const char *
const MemDepPrinter::DepTypeStr[]
92 = {
"Clobber",
"Def",
"NonFuncLocal",
"Unknown"};
94 bool MemDepPrinter::runOnFunction(
Function &
F) {
109 Deps[Inst].insert(std::make_pair(getInstTypePair(Res),
110 static_cast<BasicBlock *>(0)));
111 }
else if (
CallSite CS = cast<Value>(Inst)) {
113 MDA.getNonLocalCallDependency(CS);
115 DepSet &InstDeps = Deps[Inst];
116 for (MemoryDependenceAnalysis::NonLocalDepInfo::const_iterator
117 I = NLDI.begin(), E = NLDI.end();
I != E; ++
I) {
119 InstDeps.insert(std::make_pair(getInstTypePair(Res),
I->getBB()));
123 if (
LoadInst *
LI = dyn_cast<LoadInst>(Inst)) {
124 if (!
LI->isUnordered()) {
126 Deps[Inst].
insert(std::make_pair(getInstTypePair(0,
Unknown),
127 static_cast<BasicBlock *>(0)));
131 MDA.getNonLocalPointerDependency(Loc,
true,
LI->getParent(), NLDI);
132 }
else if (
StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
133 if (!SI->isUnordered()) {
135 Deps[Inst].insert(std::make_pair(getInstTypePair(0,
Unknown),
136 static_cast<BasicBlock *>(0)));
140 MDA.getNonLocalPointerDependency(Loc,
false, SI->getParent(), NLDI);
141 }
else if (
VAArgInst *VI = dyn_cast<VAArgInst>(Inst)) {
143 MDA.getNonLocalPointerDependency(Loc,
false, VI->getParent(), NLDI);
148 DepSet &InstDeps = Deps[Inst];
152 InstDeps.insert(std::make_pair(getInstTypePair(Res),
I->getBB()));
164 DepSetMap::const_iterator DI = Deps.find(Inst);
165 if (DI == Deps.end())
168 const DepSet &InstDeps = DI->second;
170 for (DepSet::const_iterator
I = InstDeps.begin(), E = InstDeps.end();
173 DepType type =
I->first.getInt();
177 OS << DepTypeStr[type];
void initializeMemDepPrinterPass(PassRegistry &)
static PassRegistry * getPassRegistry()
The main container class for the LLVM Intermediate Representation.
iterator insert(iterator I, const T &Elt)
LoopInfoBase< BlockT, LoopT > * LI
void WriteAsOperand(raw_ostream &, const Value *, bool PrintTy=true, const Module *Context=0)
INITIALIZE_PASS_BEGIN(MemDepPrinter,"print-memdeps","Print MemDeps of function", false, true) INITIALIZE_PASS_END(MemDepPrinter
#define INITIALIZE_PASS_DEPENDENCY(depName)
inst_iterator inst_begin(Function *F)
#define llvm_unreachable(msg)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
ID
LLVM Calling Convention Representation.
bool mayReadFromMemory() const
FunctionPass * createMemDepPrinter()
LLVM Basic Block Representation.
print Print MemDeps of false
Location - A description of a memory location.
bool mayWriteToMemory() const
A SetVector that performs no allocations if smaller than a certain size.
std::vector< NonLocalDepEntry > NonLocalDepInfo
Location getLocation(const LoadInst *LI)
Instruction * getInst() const
AnalysisUsage & addRequiredTransitive()
void print(raw_ostream &O, AssemblyAnnotationWriter *AAW=0) const
print Print MemDeps of function
inst_iterator inst_end(Function *F)
bool isNonFuncLocal() const