mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
Avoid extra DenseMap lookups in StackColoring::calculateLocalLiveness.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175487 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8a20844e27
commit
cede038867
@ -316,30 +316,44 @@ void StackColoring::calculateLocalLiveness() {
|
||||
MachineBasicBlock *BB = *PI;
|
||||
if (!BBSet.count(BB)) continue;
|
||||
|
||||
// Use an iterator to avoid repeated lookups.
|
||||
DenseMap<MachineBasicBlock*, BlockLifetimeInfo>::iterator BI =
|
||||
BlockLiveness.find(BB);
|
||||
assert(BI != BlockLiveness.end() && "Block not found");
|
||||
BlockLifetimeInfo &BlockInfo = BI->second;
|
||||
|
||||
BitVector LocalLiveIn;
|
||||
BitVector LocalLiveOut;
|
||||
|
||||
// Forward propagation from begins to ends.
|
||||
for (MachineBasicBlock::pred_iterator PI = BB->pred_begin(),
|
||||
PE = BB->pred_end(); PI != PE; ++PI)
|
||||
LocalLiveIn |= BlockLiveness[*PI].LiveOut;
|
||||
LocalLiveIn |= BlockLiveness[BB].End;
|
||||
LocalLiveIn.reset(BlockLiveness[BB].Begin);
|
||||
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);
|
||||
assert(I != BlockLiveness.end() && "Predecessor not found");
|
||||
LocalLiveIn |= I->second.LiveOut;
|
||||
}
|
||||
LocalLiveIn |= BlockInfo.End;
|
||||
LocalLiveIn.reset(BlockInfo.Begin);
|
||||
|
||||
// Reverse propagation from ends to begins.
|
||||
for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
|
||||
SE = BB->succ_end(); SI != SE; ++SI)
|
||||
LocalLiveOut |= BlockLiveness[*SI].LiveIn;
|
||||
LocalLiveOut |= BlockLiveness[BB].Begin;
|
||||
LocalLiveOut.reset(BlockLiveness[BB].End);
|
||||
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);
|
||||
assert(I != BlockLiveness.end() && "Successor not found");
|
||||
LocalLiveOut |= I->second.LiveIn;
|
||||
}
|
||||
LocalLiveOut |= BlockInfo.Begin;
|
||||
LocalLiveOut.reset(BlockInfo.End);
|
||||
|
||||
LocalLiveIn |= LocalLiveOut;
|
||||
LocalLiveOut |= LocalLiveIn;
|
||||
|
||||
// After adopting the live bits, we need to turn-off the bits which
|
||||
// are de-activated in this block.
|
||||
LocalLiveOut.reset(BlockLiveness[BB].End);
|
||||
LocalLiveIn.reset(BlockLiveness[BB].Begin);
|
||||
LocalLiveOut.reset(BlockInfo.End);
|
||||
LocalLiveIn.reset(BlockInfo.Begin);
|
||||
|
||||
// If we have both BEGIN and END markers in the same basic block then
|
||||
// we know that the BEGIN marker comes after the END, because we already
|
||||
@ -348,23 +362,23 @@ void StackColoring::calculateLocalLiveness() {
|
||||
// Want to enable the LIVE_IN and LIVE_OUT of slots that have both
|
||||
// BEGIN and END because it means that the value lives before and after
|
||||
// this basic block.
|
||||
BitVector LocalEndBegin = BlockLiveness[BB].End;
|
||||
LocalEndBegin &= BlockLiveness[BB].Begin;
|
||||
BitVector LocalEndBegin = BlockInfo.End;
|
||||
LocalEndBegin &= BlockInfo.Begin;
|
||||
LocalLiveIn |= LocalEndBegin;
|
||||
LocalLiveOut |= LocalEndBegin;
|
||||
|
||||
if (LocalLiveIn.test(BlockLiveness[BB].LiveIn)) {
|
||||
if (LocalLiveIn.test(BlockInfo.LiveIn)) {
|
||||
changed = true;
|
||||
BlockLiveness[BB].LiveIn |= LocalLiveIn;
|
||||
BlockInfo.LiveIn |= LocalLiveIn;
|
||||
|
||||
for (MachineBasicBlock::pred_iterator PI = BB->pred_begin(),
|
||||
PE = BB->pred_end(); PI != PE; ++PI)
|
||||
NextBBSet.insert(*PI);
|
||||
}
|
||||
|
||||
if (LocalLiveOut.test(BlockLiveness[BB].LiveOut)) {
|
||||
if (LocalLiveOut.test(BlockInfo.LiveOut)) {
|
||||
changed = true;
|
||||
BlockLiveness[BB].LiveOut |= LocalLiveOut;
|
||||
BlockInfo.LiveOut |= LocalLiveOut;
|
||||
|
||||
for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
|
||||
SE = BB->succ_end(); SI != SE; ++SI)
|
||||
|
Loading…
Reference in New Issue
Block a user