@@ -316,30 +316,44 @@ void StackColoring::calculateLocalLiveness() {
316
316
MachineBasicBlock *BB = *PI;
317
317
if (!BBSet.count (BB)) continue ;
318
318
319
+ // Use an iterator to avoid repeated lookups.
320
+ DenseMap<MachineBasicBlock*, BlockLifetimeInfo>::iterator BI =
321
+ BlockLiveness.find (BB);
322
+ assert (BI != BlockLiveness.end () && " Block not found" );
323
+ BlockLifetimeInfo &BlockInfo = BI->second ;
324
+
319
325
BitVector LocalLiveIn;
320
326
BitVector LocalLiveOut;
321
327
322
328
// Forward propagation from begins to ends.
323
- for (MachineBasicBlock::pred_iterator PI = BB->pred_begin (),
324
- PE = BB->pred_end (); PI != PE; ++PI)
325
- LocalLiveIn |= BlockLiveness[*PI].LiveOut ;
326
- LocalLiveIn |= BlockLiveness[BB].End ;
327
- LocalLiveIn.reset (BlockLiveness[BB].Begin );
329
+ for (MachineBasicBlock::const_pred_iterator PI = BB->pred_begin (),
330
+ PE = BB->pred_end (); PI != PE; ++PI) {
331
+ DenseMap<MachineBasicBlock*, BlockLifetimeInfo>::const_iterator I =
332
+ BlockLiveness.find (*PI);
333
+ assert (I != BlockLiveness.end () && " Predecessor not found" );
334
+ LocalLiveIn |= I->second .LiveOut ;
335
+ }
336
+ LocalLiveIn |= BlockInfo.End ;
337
+ LocalLiveIn.reset (BlockInfo.Begin );
328
338
329
339
// Reverse propagation from ends to begins.
330
- for (MachineBasicBlock::succ_iterator SI = BB->succ_begin (),
331
- SE = BB->succ_end (); SI != SE; ++SI)
332
- LocalLiveOut |= BlockLiveness[*SI].LiveIn ;
333
- LocalLiveOut |= BlockLiveness[BB].Begin ;
334
- LocalLiveOut.reset (BlockLiveness[BB].End );
340
+ for (MachineBasicBlock::const_succ_iterator SI = BB->succ_begin (),
341
+ SE = BB->succ_end (); SI != SE; ++SI) {
342
+ DenseMap<MachineBasicBlock*, BlockLifetimeInfo>::const_iterator I =
343
+ BlockLiveness.find (*SI);
344
+ assert (I != BlockLiveness.end () && " Successor not found" );
345
+ LocalLiveOut |= I->second .LiveIn ;
346
+ }
347
+ LocalLiveOut |= BlockInfo.Begin ;
348
+ LocalLiveOut.reset (BlockInfo.End );
335
349
336
350
LocalLiveIn |= LocalLiveOut;
337
351
LocalLiveOut |= LocalLiveIn;
338
352
339
353
// After adopting the live bits, we need to turn-off the bits which
340
354
// are de-activated in this block.
341
- LocalLiveOut.reset (BlockLiveness[BB] .End );
342
- LocalLiveIn.reset (BlockLiveness[BB] .Begin );
355
+ LocalLiveOut.reset (BlockInfo .End );
356
+ LocalLiveIn.reset (BlockInfo .Begin );
343
357
344
358
// If we have both BEGIN and END markers in the same basic block then
345
359
// we know that the BEGIN marker comes after the END, because we already
@@ -348,23 +362,23 @@ void StackColoring::calculateLocalLiveness() {
348
362
// Want to enable the LIVE_IN and LIVE_OUT of slots that have both
349
363
// BEGIN and END because it means that the value lives before and after
350
364
// this basic block.
351
- BitVector LocalEndBegin = BlockLiveness[BB] .End ;
352
- LocalEndBegin &= BlockLiveness[BB] .Begin ;
365
+ BitVector LocalEndBegin = BlockInfo .End ;
366
+ LocalEndBegin &= BlockInfo .Begin ;
353
367
LocalLiveIn |= LocalEndBegin;
354
368
LocalLiveOut |= LocalEndBegin;
355
369
356
- if (LocalLiveIn.test (BlockLiveness[BB] .LiveIn )) {
370
+ if (LocalLiveIn.test (BlockInfo .LiveIn )) {
357
371
changed = true ;
358
- BlockLiveness[BB] .LiveIn |= LocalLiveIn;
372
+ BlockInfo .LiveIn |= LocalLiveIn;
359
373
360
374
for (MachineBasicBlock::pred_iterator PI = BB->pred_begin (),
361
375
PE = BB->pred_end (); PI != PE; ++PI)
362
376
NextBBSet.insert (*PI);
363
377
}
364
378
365
- if (LocalLiveOut.test (BlockLiveness[BB] .LiveOut )) {
379
+ if (LocalLiveOut.test (BlockInfo .LiveOut )) {
366
380
changed = true ;
367
- BlockLiveness[BB] .LiveOut |= LocalLiveOut;
381
+ BlockInfo .LiveOut |= LocalLiveOut;
368
382
369
383
for (MachineBasicBlock::succ_iterator SI = BB->succ_begin (),
370
384
SE = BB->succ_end (); SI != SE; ++SI)
0 commit comments