Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit cbc6d79

Browse files
committed
Make the dump() function const and reduce the number of hash lookups it performs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175485 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 252d798 commit cbc6d79

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

lib/CodeGen/StackColoring.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class StackColoring : public MachineFunctionPass {
144144

145145
private:
146146
/// Debug.
147-
void dump();
147+
void dump() const;
148148

149149
/// Removes all of the lifetime marker instructions from the function.
150150
/// \returns true if any markers were removed.
@@ -199,30 +199,36 @@ void StackColoring::getAnalysisUsage(AnalysisUsage &AU) const {
199199
MachineFunctionPass::getAnalysisUsage(AU);
200200
}
201201

202-
void StackColoring::dump() {
202+
void StackColoring::dump() const {
203203
for (df_iterator<MachineFunction*> FI = df_begin(MF), FE = df_end(MF);
204204
FI != FE; ++FI) {
205-
DEBUG(dbgs()<<"Inspecting block #"<<BasicBlocks[*FI]<<
205+
DEBUG(dbgs()<<"Inspecting block #"<<BasicBlocks.lookup(*FI)<<
206206
" ["<<FI->getName()<<"]\n");
207+
208+
DenseMap<MachineBasicBlock*, BlockLifetimeInfo>::const_iterator BI =
209+
BlockLiveness.find(*FI);
210+
assert(BI != BlockLiveness.end() && "Block not found");
211+
const BlockLifetimeInfo &BlockInfo = BI->second;
212+
207213
DEBUG(dbgs()<<"BEGIN : {");
208-
for (unsigned i=0; i < BlockLiveness[*FI].Begin.size(); ++i)
209-
DEBUG(dbgs()<<BlockLiveness[*FI].Begin.test(i)<<" ");
214+
for (unsigned i=0; i < BlockInfo.Begin.size(); ++i)
215+
DEBUG(dbgs()<<BlockInfo.Begin.test(i)<<" ");
210216
DEBUG(dbgs()<<"}\n");
211217

212218
DEBUG(dbgs()<<"END : {");
213-
for (unsigned i=0; i < BlockLiveness[*FI].End.size(); ++i)
214-
DEBUG(dbgs()<<BlockLiveness[*FI].End.test(i)<<" ");
219+
for (unsigned i=0; i < BlockInfo.End.size(); ++i)
220+
DEBUG(dbgs()<<BlockInfo.End.test(i)<<" ");
215221

216222
DEBUG(dbgs()<<"}\n");
217223

218224
DEBUG(dbgs()<<"LIVE_IN: {");
219-
for (unsigned i=0; i < BlockLiveness[*FI].LiveIn.size(); ++i)
220-
DEBUG(dbgs()<<BlockLiveness[*FI].LiveIn.test(i)<<" ");
225+
for (unsigned i=0; i < BlockInfo.LiveIn.size(); ++i)
226+
DEBUG(dbgs()<<BlockInfo.LiveIn.test(i)<<" ");
221227

222228
DEBUG(dbgs()<<"}\n");
223229
DEBUG(dbgs()<<"LIVEOUT: {");
224-
for (unsigned i=0; i < BlockLiveness[*FI].LiveOut.size(); ++i)
225-
DEBUG(dbgs()<<BlockLiveness[*FI].LiveOut.test(i)<<" ");
230+
for (unsigned i=0; i < BlockInfo.LiveOut.size(); ++i)
231+
DEBUG(dbgs()<<BlockInfo.LiveOut.test(i)<<" ");
226232
DEBUG(dbgs()<<"}\n");
227233
}
228234
}

0 commit comments

Comments
 (0)