Skip to content

Commit

Permalink
Make the dump() function const and reduce the number of hash lookups …
Browse files Browse the repository at this point in the history
…it performs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175485 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
topperc committed Feb 19, 2013
1 parent 252d798 commit cbc6d79
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions lib/CodeGen/StackColoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class StackColoring : public MachineFunctionPass {

private:
/// Debug.
void dump();
void dump() const;

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

void StackColoring::dump() {
void StackColoring::dump() const {
for (df_iterator<MachineFunction*> FI = df_begin(MF), FE = df_end(MF);
FI != FE; ++FI) {
DEBUG(dbgs()<<"Inspecting block #"<<BasicBlocks[*FI]<<
DEBUG(dbgs()<<"Inspecting block #"<<BasicBlocks.lookup(*FI)<<
" ["<<FI->getName()<<"]\n");

DenseMap<MachineBasicBlock*, BlockLifetimeInfo>::const_iterator BI =
BlockLiveness.find(*FI);
assert(BI != BlockLiveness.end() && "Block not found");
const BlockLifetimeInfo &BlockInfo = BI->second;

DEBUG(dbgs()<<"BEGIN : {");
for (unsigned i=0; i < BlockLiveness[*FI].Begin.size(); ++i)
DEBUG(dbgs()<<BlockLiveness[*FI].Begin.test(i)<<" ");
for (unsigned i=0; i < BlockInfo.Begin.size(); ++i)
DEBUG(dbgs()<<BlockInfo.Begin.test(i)<<" ");
DEBUG(dbgs()<<"}\n");

DEBUG(dbgs()<<"END : {");
for (unsigned i=0; i < BlockLiveness[*FI].End.size(); ++i)
DEBUG(dbgs()<<BlockLiveness[*FI].End.test(i)<<" ");
for (unsigned i=0; i < BlockInfo.End.size(); ++i)
DEBUG(dbgs()<<BlockInfo.End.test(i)<<" ");

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

DEBUG(dbgs()<<"LIVE_IN: {");
for (unsigned i=0; i < BlockLiveness[*FI].LiveIn.size(); ++i)
DEBUG(dbgs()<<BlockLiveness[*FI].LiveIn.test(i)<<" ");
for (unsigned i=0; i < BlockInfo.LiveIn.size(); ++i)
DEBUG(dbgs()<<BlockInfo.LiveIn.test(i)<<" ");

DEBUG(dbgs()<<"}\n");
DEBUG(dbgs()<<"LIVEOUT: {");
for (unsigned i=0; i < BlockLiveness[*FI].LiveOut.size(); ++i)
DEBUG(dbgs()<<BlockLiveness[*FI].LiveOut.test(i)<<" ");
for (unsigned i=0; i < BlockInfo.LiveOut.size(); ++i)
DEBUG(dbgs()<<BlockInfo.LiveOut.test(i)<<" ");
DEBUG(dbgs()<<"}\n");
}
}
Expand Down

0 comments on commit cbc6d79

Please sign in to comment.