diff options
author | Craig Topper <craig.topper@gmail.com> | 2013-02-19 05:32:02 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2013-02-19 05:32:02 +0000 |
commit | 04fbcb59432c085bb284501dcea9693f435a417b (patch) | |
tree | 589b9892de9b600ea489f06432c43d273880dc2b | |
parent | cede03886712e18b697f9ec91311d4a8df60c734 (diff) |
Const-correct the stack coloring code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175488 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/StackColoring.cpp | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/lib/CodeGen/StackColoring.cpp b/lib/CodeGen/StackColoring.cpp index f3da088b7c..6c5212b026 100644 --- a/lib/CodeGen/StackColoring.cpp +++ b/lib/CodeGen/StackColoring.cpp @@ -102,12 +102,13 @@ class StackColoring : public MachineFunctionPass { }; /// Maps active slots (per bit) for each basic block. - DenseMap<MachineBasicBlock*, BlockLifetimeInfo> BlockLiveness; + typedef DenseMap<const MachineBasicBlock*, BlockLifetimeInfo> LivenessMap; + LivenessMap BlockLiveness; /// Maps serial numbers to basic blocks. - DenseMap<MachineBasicBlock*, int> BasicBlocks; + DenseMap<const MachineBasicBlock*, int> BasicBlocks; /// Maps basic blocks to a serial number. - SmallVector<MachineBasicBlock*, 8> BasicBlockNumbering; + SmallVector<const MachineBasicBlock*, 8> BasicBlockNumbering; /// Maps liveness intervals for each slot. SmallVector<LiveInterval*, 16> Intervals; @@ -205,8 +206,7 @@ void StackColoring::dump() const { DEBUG(dbgs()<<"Inspecting block #"<<BasicBlocks.lookup(*FI)<< " ["<<FI->getName()<<"]\n"); - DenseMap<MachineBasicBlock*, BlockLifetimeInfo>::const_iterator BI = - BlockLiveness.find(*FI); + LivenessMap::const_iterator BI = BlockLiveness.find(*FI); assert(BI != BlockLiveness.end() && "Block not found"); const BlockLifetimeInfo &BlockInfo = BI->second; @@ -299,26 +299,25 @@ void StackColoring::calculateLocalLiveness() { // formulation, and END is equivalent to GEN. The result of this computation // is a map from blocks to bitvectors where the bitvectors represent which // allocas are live in/out of that block. - SmallPtrSet<MachineBasicBlock*, 8> BBSet(BasicBlockNumbering.begin(), - BasicBlockNumbering.end()); + SmallPtrSet<const MachineBasicBlock*, 8> BBSet(BasicBlockNumbering.begin(), + BasicBlockNumbering.end()); unsigned NumSSMIters = 0; bool changed = true; while (changed) { changed = false; ++NumSSMIters; - SmallPtrSet<MachineBasicBlock*, 8> NextBBSet; + SmallPtrSet<const MachineBasicBlock*, 8> NextBBSet; - for (SmallVector<MachineBasicBlock*, 8>::iterator + for (SmallVector<const MachineBasicBlock*, 8>::iterator PI = BasicBlockNumbering.begin(), PE = BasicBlockNumbering.end(); PI != PE; ++PI) { - MachineBasicBlock *BB = *PI; + const MachineBasicBlock *BB = *PI; if (!BBSet.count(BB)) continue; // Use an iterator to avoid repeated lookups. - DenseMap<MachineBasicBlock*, BlockLifetimeInfo>::iterator BI = - BlockLiveness.find(BB); + LivenessMap::iterator BI = BlockLiveness.find(BB); assert(BI != BlockLiveness.end() && "Block not found"); BlockLifetimeInfo &BlockInfo = BI->second; @@ -328,8 +327,7 @@ void StackColoring::calculateLocalLiveness() { // Forward propagation from begins to ends. for (MachineBasicBlock::const_pred_iterator PI = BB->pred_begin(), PE = BB->pred_end(); PI != PE; ++PI) { - DenseMap<MachineBasicBlock*, BlockLifetimeInfo>::const_iterator I = - BlockLiveness.find(*PI); + LivenessMap::const_iterator I = BlockLiveness.find(*PI); assert(I != BlockLiveness.end() && "Predecessor not found"); LocalLiveIn |= I->second.LiveOut; } @@ -339,8 +337,7 @@ void StackColoring::calculateLocalLiveness() { // Reverse propagation from ends to begins. for (MachineBasicBlock::const_succ_iterator SI = BB->succ_begin(), SE = BB->succ_end(); SI != SE; ++SI) { - DenseMap<MachineBasicBlock*, BlockLifetimeInfo>::const_iterator I = - BlockLiveness.find(*SI); + LivenessMap::const_iterator I = BlockLiveness.find(*SI); assert(I != BlockLiveness.end() && "Successor not found"); LocalLiveOut |= I->second.LiveIn; } @@ -371,7 +368,7 @@ void StackColoring::calculateLocalLiveness() { changed = true; BlockInfo.LiveIn |= LocalLiveIn; - for (MachineBasicBlock::pred_iterator PI = BB->pred_begin(), + for (MachineBasicBlock::const_pred_iterator PI = BB->pred_begin(), PE = BB->pred_end(); PI != PE; ++PI) NextBBSet.insert(*PI); } @@ -380,7 +377,7 @@ void StackColoring::calculateLocalLiveness() { changed = true; BlockInfo.LiveOut |= LocalLiveOut; - for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(), + for (MachineBasicBlock::const_succ_iterator SI = BB->succ_begin(), SE = BB->succ_end(); SI != SE; ++SI) NextBBSet.insert(*SI); } |