diff options
-rw-r--r-- | llvm/lib/CodeGen/StackColoring.cpp | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp index d93fc6aff36..54f0f2b9e08 100644 --- a/llvm/lib/CodeGen/StackColoring.cpp +++ b/llvm/lib/CodeGen/StackColoring.cpp @@ -30,8 +30,6 @@ #include "llvm/Analysis/ValueTracking.h" #include "llvm/CodeGen/LiveInterval.h" #include "llvm/CodeGen/MachineBasicBlock.h" -#include "llvm/CodeGen/MachineBranchProbabilityInfo.h" -#include "llvm/CodeGen/MachineDominators.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineLoopInfo.h" @@ -44,7 +42,6 @@ #include "llvm/CodeGen/StackProtector.h" #include "llvm/CodeGen/WinEHFuncInfo.h" #include "llvm/IR/DebugInfo.h" -#include "llvm/IR/Dominators.h" #include "llvm/IR/Function.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" @@ -137,6 +134,9 @@ public: private: /// Debug. void dump() const; + void dumpIntervals() const; + void dumpBB(MachineBasicBlock *MBB) const; + void dumpBV(const char *tag, const BitVector &BV) const; /// Removes all of the lifetime marker instructions from the function. /// \returns true if any markers were removed. @@ -179,49 +179,48 @@ char &llvm::StackColoringID = StackColoring::ID; INITIALIZE_PASS_BEGIN(StackColoring, "stack-coloring", "Merge disjoint stack slots", false, false) -INITIALIZE_PASS_DEPENDENCY(MachineDominatorTree) INITIALIZE_PASS_DEPENDENCY(SlotIndexes) INITIALIZE_PASS_DEPENDENCY(StackProtector) INITIALIZE_PASS_END(StackColoring, "stack-coloring", "Merge disjoint stack slots", false, false) void StackColoring::getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired<MachineDominatorTree>(); - AU.addPreserved<MachineDominatorTree>(); AU.addRequired<SlotIndexes>(); AU.addRequired<StackProtector>(); MachineFunctionPass::getAnalysisUsage(AU); } -LLVM_DUMP_METHOD void StackColoring::dump() const { - for (MachineBasicBlock *MBB : depth_first(MF)) { - DEBUG(dbgs() << "Inspecting block #" << BasicBlocks.lookup(MBB) << " [" - << MBB->getName() << "]\n"); - - LivenessMap::const_iterator BI = BlockLiveness.find(MBB); - assert(BI != BlockLiveness.end() && "Block not found"); - const BlockLifetimeInfo &BlockInfo = BI->second; - - DEBUG(dbgs()<<"BEGIN : {"); - for (unsigned i=0; i < BlockInfo.Begin.size(); ++i) - DEBUG(dbgs()<<BlockInfo.Begin.test(i)<<" "); - DEBUG(dbgs()<<"}\n"); +LLVM_DUMP_METHOD void StackColoring::dumpBV(const char *tag, + const BitVector &BV) const { + DEBUG(dbgs() << tag << " : { "); + for (unsigned I = 0, E = BV.size(); I != E; ++I) + DEBUG(dbgs() << BV.test(I) << " "); + DEBUG(dbgs() << "}\n"); +} - DEBUG(dbgs()<<"END : {"); - for (unsigned i=0; i < BlockInfo.End.size(); ++i) - DEBUG(dbgs()<<BlockInfo.End.test(i)<<" "); +LLVM_DUMP_METHOD void StackColoring::dumpBB(MachineBasicBlock *MBB) const { + LivenessMap::const_iterator BI = BlockLiveness.find(MBB); + assert(BI != BlockLiveness.end() && "Block not found"); + const BlockLifetimeInfo &BlockInfo = BI->second; - DEBUG(dbgs()<<"}\n"); + dumpBV("BEGIN", BlockInfo.Begin); + dumpBV("END", BlockInfo.End); + dumpBV("LIVE_IN", BlockInfo.LiveIn); + dumpBV("LIVE_OUT", BlockInfo.LiveOut); +} - DEBUG(dbgs()<<"LIVE_IN: {"); - for (unsigned i=0; i < BlockInfo.LiveIn.size(); ++i) - DEBUG(dbgs()<<BlockInfo.LiveIn.test(i)<<" "); +LLVM_DUMP_METHOD void StackColoring::dump() const { + for (MachineBasicBlock *MBB : depth_first(MF)) { + DEBUG(dbgs() << "Inspecting block #" << MBB->getNumber() << " [" + << MBB->getName() << "]\n"); + DEBUG(dumpBB(MBB)); + } +} - DEBUG(dbgs()<<"}\n"); - DEBUG(dbgs()<<"LIVEOUT: {"); - for (unsigned i=0; i < BlockInfo.LiveOut.size(); ++i) - DEBUG(dbgs()<<BlockInfo.LiveOut.test(i)<<" "); - DEBUG(dbgs()<<"}\n"); +LLVM_DUMP_METHOD void StackColoring::dumpIntervals() const { + for (unsigned I = 0, E = Intervals.size(); I != E; ++I) { + DEBUG(dbgs() << "Interval[" << I << "]:\n"); + DEBUG(Intervals[I]->dump()); } } |