diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2007-05-08 19:00:00 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2007-05-08 19:00:00 +0000 |
| commit | 9e17872c1df807bdc6442908f0c121d468c38519 (patch) | |
| tree | 21f34c1a670279057b7049a42534d36af313aa65 /llvm/lib/CodeGen | |
| parent | 6c6cea91fcb85a2c182564c4a29ad45f6e2295b6 (diff) | |
| download | bcm5719-llvm-9e17872c1df807bdc6442908f0c121d468c38519.tar.gz bcm5719-llvm-9e17872c1df807bdc6442908f0c121d468c38519.zip | |
Eliminate MarkVirtRegAliveInBlock recursion.
llvm-svn: 36943
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/LiveVariables.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/LiveVariables.cpp b/llvm/lib/CodeGen/LiveVariables.cpp index 4afeb28b1a5..9d2d29057d6 100644 --- a/llvm/lib/CodeGen/LiveVariables.cpp +++ b/llvm/lib/CodeGen/LiveVariables.cpp @@ -112,7 +112,8 @@ bool LiveVariables::ModifiesRegister(MachineInstr *MI, unsigned Reg) const { } void LiveVariables::MarkVirtRegAliveInBlock(VarInfo &VRInfo, - MachineBasicBlock *MBB) { + MachineBasicBlock *MBB, + std::vector<MachineBasicBlock*> &WorkList) { unsigned BBNum = MBB->getNumber(); // Check to see if this basic block is one of the killing blocks. If so, @@ -131,11 +132,23 @@ void LiveVariables::MarkVirtRegAliveInBlock(VarInfo &VRInfo, // Mark the variable known alive in this bb VRInfo.AliveBlocks[BBNum] = true; - for (MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(), - E = MBB->pred_end(); PI != E; ++PI) - MarkVirtRegAliveInBlock(VRInfo, *PI); + for (MachineBasicBlock::const_pred_reverse_iterator PI = MBB->pred_rbegin(), + E = MBB->pred_rend(); PI != E; ++PI) + WorkList.push_back(*PI); +} + +void LiveVariables::MarkVirtRegAliveInBlock(VarInfo &VRInfo, + MachineBasicBlock *MBB) { + std::vector<MachineBasicBlock*> WorkList; + MarkVirtRegAliveInBlock(VRInfo, MBB, WorkList); + while (!WorkList.empty()) { + MachineBasicBlock *Pred = WorkList.back(); + WorkList.pop_back(); + MarkVirtRegAliveInBlock(VRInfo, Pred, WorkList); + } } + void LiveVariables::HandleVirtRegUse(VarInfo &VRInfo, MachineBasicBlock *MBB, MachineInstr *MI) { assert(VRInfo.DefInst && "Register use before def!"); |

