diff options
author | Dan Gohman <gohman@apple.com> | 2008-09-21 21:11:41 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-09-21 21:11:41 +0000 |
commit | 3bdf5fe71ad2d48d81d013b16181766bde295f58 (patch) | |
tree | ac81064df2b9eb4a72a57624e718505e97ab4660 /lib/CodeGen/LiveVariables.cpp | |
parent | 4893c067b767f5955ffedd722f33c11750c3e52b (diff) |
Factor out code into HandleVirtRegDef, for consistency with
Handle{Virt,Phys}Reg{Def,Use}. Remove a redundant check
for register zero, and redundant checks for isPhysicalRegister.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56412 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveVariables.cpp')
-rw-r--r-- | lib/CodeGen/LiveVariables.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/CodeGen/LiveVariables.cpp b/lib/CodeGen/LiveVariables.cpp index 00a5869cc1..7c4b77f41b 100644 --- a/lib/CodeGen/LiveVariables.cpp +++ b/lib/CodeGen/LiveVariables.cpp @@ -177,6 +177,14 @@ void LiveVariables::HandleVirtRegUse(unsigned reg, MachineBasicBlock *MBB, MarkVirtRegAliveInBlock(VRInfo, MRI->getVRegDef(reg)->getParent(), *PI); } +void LiveVariables::HandleVirtRegDef(unsigned Reg, MachineInstr *MI) { + VarInfo &VRInfo = getVarInfo(Reg); + + if (VRInfo.AliveBlocks.none()) + // If vr is not alive in any block, then defaults to dead. + VRInfo.Kills.push_back(MI); +} + /// FindLastPartialDef - Return the last partial def of the specified register. /// Also returns the sub-register that's defined. MachineInstr *LiveVariables::FindLastPartialDef(unsigned Reg, @@ -552,8 +560,6 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &mf) { const MachineOperand &MO = MI->getOperand(i); if (MO.isRegister() && MO.getReg()) { unsigned MOReg = MO.getReg(); - if (!MOReg) - continue; if (MO.isUse()) UseRegs.push_back(MOReg); if (MO.isDef()) @@ -566,24 +572,17 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &mf) { unsigned MOReg = UseRegs[i]; if (TargetRegisterInfo::isVirtualRegister(MOReg)) HandleVirtRegUse(MOReg, MBB, MI); - else if (TargetRegisterInfo::isPhysicalRegister(MOReg) && - !ReservedRegisters[MOReg]) + else if (!ReservedRegisters[MOReg]) HandlePhysRegUse(MOReg, MI); } // Process all defs. for (unsigned i = 0, e = DefRegs.size(); i != e; ++i) { unsigned MOReg = DefRegs[i]; - if (TargetRegisterInfo::isVirtualRegister(MOReg)) { - VarInfo &VRInfo = getVarInfo(MOReg); - - if (VRInfo.AliveBlocks.none()) - // If vr is not alive in any block, then defaults to dead. - VRInfo.Kills.push_back(MI); - } else if (TargetRegisterInfo::isPhysicalRegister(MOReg) && - !ReservedRegisters[MOReg]) { + if (TargetRegisterInfo::isVirtualRegister(MOReg)) + HandleVirtRegDef(MOReg, MI); + else if (!ReservedRegisters[MOReg]) HandlePhysRegDef(MOReg, MI); - } } } |