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

Commit 04fbcb5

Browse files
committed
Const-correct the stack coloring code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175488 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent cede038 commit 04fbcb5

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

lib/CodeGen/StackColoring.cpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ class StackColoring : public MachineFunctionPass {
102102
};
103103

104104
/// Maps active slots (per bit) for each basic block.
105-
DenseMap<MachineBasicBlock*, BlockLifetimeInfo> BlockLiveness;
105+
typedef DenseMap<const MachineBasicBlock*, BlockLifetimeInfo> LivenessMap;
106+
LivenessMap BlockLiveness;
106107

107108
/// Maps serial numbers to basic blocks.
108-
DenseMap<MachineBasicBlock*, int> BasicBlocks;
109+
DenseMap<const MachineBasicBlock*, int> BasicBlocks;
109110
/// Maps basic blocks to a serial number.
110-
SmallVector<MachineBasicBlock*, 8> BasicBlockNumbering;
111+
SmallVector<const MachineBasicBlock*, 8> BasicBlockNumbering;
111112

112113
/// Maps liveness intervals for each slot.
113114
SmallVector<LiveInterval*, 16> Intervals;
@@ -205,8 +206,7 @@ void StackColoring::dump() const {
205206
DEBUG(dbgs()<<"Inspecting block #"<<BasicBlocks.lookup(*FI)<<
206207
" ["<<FI->getName()<<"]\n");
207208

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

@@ -299,26 +299,25 @@ void StackColoring::calculateLocalLiveness() {
299299
// formulation, and END is equivalent to GEN. The result of this computation
300300
// is a map from blocks to bitvectors where the bitvectors represent which
301301
// allocas are live in/out of that block.
302-
SmallPtrSet<MachineBasicBlock*, 8> BBSet(BasicBlockNumbering.begin(),
303-
BasicBlockNumbering.end());
302+
SmallPtrSet<const MachineBasicBlock*, 8> BBSet(BasicBlockNumbering.begin(),
303+
BasicBlockNumbering.end());
304304
unsigned NumSSMIters = 0;
305305
bool changed = true;
306306
while (changed) {
307307
changed = false;
308308
++NumSSMIters;
309309

310-
SmallPtrSet<MachineBasicBlock*, 8> NextBBSet;
310+
SmallPtrSet<const MachineBasicBlock*, 8> NextBBSet;
311311

312-
for (SmallVector<MachineBasicBlock*, 8>::iterator
312+
for (SmallVector<const MachineBasicBlock*, 8>::iterator
313313
PI = BasicBlockNumbering.begin(), PE = BasicBlockNumbering.end();
314314
PI != PE; ++PI) {
315315

316-
MachineBasicBlock *BB = *PI;
316+
const MachineBasicBlock *BB = *PI;
317317
if (!BBSet.count(BB)) continue;
318318

319319
// Use an iterator to avoid repeated lookups.
320-
DenseMap<MachineBasicBlock*, BlockLifetimeInfo>::iterator BI =
321-
BlockLiveness.find(BB);
320+
LivenessMap::iterator BI = BlockLiveness.find(BB);
322321
assert(BI != BlockLiveness.end() && "Block not found");
323322
BlockLifetimeInfo &BlockInfo = BI->second;
324323

@@ -328,8 +327,7 @@ void StackColoring::calculateLocalLiveness() {
328327
// Forward propagation from begins to ends.
329328
for (MachineBasicBlock::const_pred_iterator PI = BB->pred_begin(),
330329
PE = BB->pred_end(); PI != PE; ++PI) {
331-
DenseMap<MachineBasicBlock*, BlockLifetimeInfo>::const_iterator I =
332-
BlockLiveness.find(*PI);
330+
LivenessMap::const_iterator I = BlockLiveness.find(*PI);
333331
assert(I != BlockLiveness.end() && "Predecessor not found");
334332
LocalLiveIn |= I->second.LiveOut;
335333
}
@@ -339,8 +337,7 @@ void StackColoring::calculateLocalLiveness() {
339337
// Reverse propagation from ends to begins.
340338
for (MachineBasicBlock::const_succ_iterator SI = BB->succ_begin(),
341339
SE = BB->succ_end(); SI != SE; ++SI) {
342-
DenseMap<MachineBasicBlock*, BlockLifetimeInfo>::const_iterator I =
343-
BlockLiveness.find(*SI);
340+
LivenessMap::const_iterator I = BlockLiveness.find(*SI);
344341
assert(I != BlockLiveness.end() && "Successor not found");
345342
LocalLiveOut |= I->second.LiveIn;
346343
}
@@ -371,7 +368,7 @@ void StackColoring::calculateLocalLiveness() {
371368
changed = true;
372369
BlockInfo.LiveIn |= LocalLiveIn;
373370

374-
for (MachineBasicBlock::pred_iterator PI = BB->pred_begin(),
371+
for (MachineBasicBlock::const_pred_iterator PI = BB->pred_begin(),
375372
PE = BB->pred_end(); PI != PE; ++PI)
376373
NextBBSet.insert(*PI);
377374
}
@@ -380,7 +377,7 @@ void StackColoring::calculateLocalLiveness() {
380377
changed = true;
381378
BlockInfo.LiveOut |= LocalLiveOut;
382379

383-
for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
380+
for (MachineBasicBlock::const_succ_iterator SI = BB->succ_begin(),
384381
SE = BB->succ_end(); SI != SE; ++SI)
385382
NextBBSet.insert(*SI);
386383
}

0 commit comments

Comments
 (0)