comparison lib/Analysis/MemDepPrinter.cpp @ 95:afa8332a0e37 LLVM3.8

LLVM 3.8
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Tue, 13 Oct 2015 17:48:58 +0900
parents 60c9769439b8
children 1172e4bd9c6f
comparison
equal deleted inserted replaced
84:f3e34b893a5f 95:afa8332a0e37
47 bool runOnFunction(Function &F) override; 47 bool runOnFunction(Function &F) override;
48 48
49 void print(raw_ostream &OS, const Module * = nullptr) const override; 49 void print(raw_ostream &OS, const Module * = nullptr) const override;
50 50
51 void getAnalysisUsage(AnalysisUsage &AU) const override { 51 void getAnalysisUsage(AnalysisUsage &AU) const override {
52 AU.addRequiredTransitive<AliasAnalysis>(); 52 AU.addRequiredTransitive<AAResultsWrapperPass>();
53 AU.addRequiredTransitive<MemoryDependenceAnalysis>(); 53 AU.addRequiredTransitive<MemoryDependenceAnalysis>();
54 AU.setPreservesAll(); 54 AU.setPreservesAll();
55 } 55 }
56 56
57 void releaseMemory() override { 57 void releaseMemory() override {
94 this->F = &F; 94 this->F = &F;
95 MemoryDependenceAnalysis &MDA = getAnalysis<MemoryDependenceAnalysis>(); 95 MemoryDependenceAnalysis &MDA = getAnalysis<MemoryDependenceAnalysis>();
96 96
97 // All this code uses non-const interfaces because MemDep is not 97 // All this code uses non-const interfaces because MemDep is not
98 // const-friendly, though nothing is actually modified. 98 // const-friendly, though nothing is actually modified.
99 for (auto &I: inst_range(F)) { 99 for (auto &I : instructions(F)) {
100 Instruction *Inst = &I; 100 Instruction *Inst = &I;
101 101
102 if (!Inst->mayReadFromMemory() && !Inst->mayWriteToMemory()) 102 if (!Inst->mayReadFromMemory() && !Inst->mayWriteToMemory())
103 continue; 103 continue;
104 104
105 MemDepResult Res = MDA.getDependency(Inst); 105 MemDepResult Res = MDA.getDependency(Inst);
106 if (!Res.isNonLocal()) { 106 if (!Res.isNonLocal()) {
107 Deps[Inst].insert(std::make_pair(getInstTypePair(Res), 107 Deps[Inst].insert(std::make_pair(getInstTypePair(Res),
108 static_cast<BasicBlock *>(nullptr))); 108 static_cast<BasicBlock *>(nullptr)));
109 } else if (CallSite CS = cast<Value>(Inst)) { 109 } else if (auto CS = CallSite(Inst)) {
110 const MemoryDependenceAnalysis::NonLocalDepInfo &NLDI = 110 const MemoryDependenceAnalysis::NonLocalDepInfo &NLDI =
111 MDA.getNonLocalCallDependency(CS); 111 MDA.getNonLocalCallDependency(CS);
112 112
113 DepSet &InstDeps = Deps[Inst]; 113 DepSet &InstDeps = Deps[Inst];
114 for (MemoryDependenceAnalysis::NonLocalDepInfo::const_iterator 114 for (MemoryDependenceAnalysis::NonLocalDepInfo::const_iterator
133 133
134 return false; 134 return false;
135 } 135 }
136 136
137 void MemDepPrinter::print(raw_ostream &OS, const Module *M) const { 137 void MemDepPrinter::print(raw_ostream &OS, const Module *M) const {
138 for (auto &I: inst_range(*F)) { 138 for (const auto &I : instructions(*F)) {
139 const Instruction *Inst = &I; 139 const Instruction *Inst = &I;
140 140
141 DepSetMap::const_iterator DI = Deps.find(Inst); 141 DepSetMap::const_iterator DI = Deps.find(Inst);
142 if (DI == Deps.end()) 142 if (DI == Deps.end())
143 continue; 143 continue;
144 144
145 const DepSet &InstDeps = DI->second; 145 const DepSet &InstDeps = DI->second;
146 146
147 for (auto &I: InstDeps) { 147 for (const auto &I : InstDeps) {
148 const Instruction *DepInst = I.first.getPointer(); 148 const Instruction *DepInst = I.first.getPointer();
149 DepType type = I.first.getInt(); 149 DepType type = I.first.getInt();
150 const BasicBlock *DepBB = I.second; 150 const BasicBlock *DepBB = I.second;
151 151
152 OS << " "; 152 OS << " ";