diff options
author | Pete Cooper <peter_cooper@apple.com> | 2015-05-05 18:31:31 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2015-05-05 18:31:31 +0000 |
commit | bbd1c727d17afb1d8327b8a49eb36a716c9af8c0 (patch) | |
tree | 721f7ea06b12edbb7ff287bd6ca7377bfbc6e86e /llvm/lib/CodeGen/LivePhysRegs.cpp | |
parent | 32a0bee2bb467a128b3d99631e6a866c61e1dd34 (diff) | |
download | bcm5719-llvm-bbd1c727d17afb1d8327b8a49eb36a716c9af8c0.tar.gz bcm5719-llvm-bbd1c727d17afb1d8327b8a49eb36a716c9af8c0.zip |
Refactor UpdatePredRedefs and StepForward to avoid duplication. NFC
The code was basically the same here already. Just added an out parameter for a vector of seen defs so that UpdatePredRedefs can call StepForward first, then do its own post processing on the seen defs.
Will be used in the next commit to also handle regmasks.
llvm-svn: 236514
Diffstat (limited to 'llvm/lib/CodeGen/LivePhysRegs.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LivePhysRegs.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/LivePhysRegs.cpp b/llvm/lib/CodeGen/LivePhysRegs.cpp index 89567eff517..b6369275051 100644 --- a/llvm/lib/CodeGen/LivePhysRegs.cpp +++ b/llvm/lib/CodeGen/LivePhysRegs.cpp @@ -22,12 +22,17 @@ using namespace llvm; /// \brief Remove all registers from the set that get clobbered by the register /// mask. -void LivePhysRegs::removeRegsInMask(const MachineOperand &MO) { +/// The clobbers set will be the list of live registers clobbered +/// by the regmask. +void LivePhysRegs::removeRegsInMask(const MachineOperand &MO, + SmallVectorImpl<std::pair<unsigned, const MachineOperand*>> *Clobbers) { SparseSet<unsigned>::iterator LRI = LiveRegs.begin(); while (LRI != LiveRegs.end()) { - if (MO.clobbersPhysReg(*LRI)) + if (MO.clobbersPhysReg(*LRI)) { + if (Clobbers) + Clobbers->push_back(std::make_pair(*LRI, &MO)); LRI = LiveRegs.erase(LRI); - else + } else ++LRI; } } @@ -45,7 +50,7 @@ void LivePhysRegs::stepBackward(const MachineInstr &MI) { continue; removeReg(Reg); } else if (O->isRegMask()) - removeRegsInMask(*O); + removeRegsInMask(*O, nullptr); } // Add uses to the set. @@ -63,8 +68,8 @@ void LivePhysRegs::stepBackward(const MachineInstr &MI) { /// killed-uses, add defs. This is the not recommended way, because it depends /// on accurate kill flags. If possible use stepBackwards() instead of this /// function. -void LivePhysRegs::stepForward(const MachineInstr &MI) { - SmallVector<unsigned, 4> Defs; +void LivePhysRegs::stepForward(const MachineInstr &MI, + SmallVectorImpl<std::pair<unsigned, const MachineOperand*>> &Clobbers) { // Remove killed registers from the set. for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { if (O->isReg()) { @@ -73,7 +78,7 @@ void LivePhysRegs::stepForward(const MachineInstr &MI) { continue; if (O->isDef()) { if (!O->isDead()) - Defs.push_back(Reg); + Clobbers.push_back(std::make_pair(Reg, &*O)); } else { if (!O->isKill()) continue; @@ -81,12 +86,12 @@ void LivePhysRegs::stepForward(const MachineInstr &MI) { removeReg(Reg); } } else if (O->isRegMask()) - removeRegsInMask(*O); + removeRegsInMask(*O, &Clobbers); } // Add defs to the set. - for (unsigned i = 0, e = Defs.size(); i != e; ++i) - addReg(Defs[i]); + for (auto Reg : Clobbers) + addReg(Reg.first); } /// Prin the currently live registers to OS. |