diff options
author | Andrew Trick <atrick@apple.com> | 2013-10-14 20:45:19 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2013-10-14 20:45:19 +0000 |
commit | 3f4d6c6538c7a68bf685f21ce88164f76a9ca815 (patch) | |
tree | fb8bc396d25cee2d7076bcad8df355095e0347fa | |
parent | 276dd453f07602958d1aa79d1f910c3d6225737d (diff) | |
download | bcm5719-llvm-3f4d6c6538c7a68bf685f21ce88164f76a9ca815.tar.gz bcm5719-llvm-3f4d6c6538c7a68bf685f21ce88164f76a9ca815.zip |
LiveRegUnits::removeRegsInMask safety.
Clobbering is exclusive not inclusive on register units.
For liveness, we need to consider all the preserved registers.
e.g. A regmask that clobbers YMM0 may preserve XMM0.
Units are only clobbered when all super-registers are clobbered.
llvm-svn: 192623
-rw-r--r-- | llvm/lib/CodeGen/LiveRegUnits.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/LiveRegUnits.cpp b/llvm/lib/CodeGen/LiveRegUnits.cpp index c9fa40e25d1..5ff27dd1aaf 100644 --- a/llvm/lib/CodeGen/LiveRegUnits.cpp +++ b/llvm/lib/CodeGen/LiveRegUnits.cpp @@ -17,21 +17,30 @@ #include "llvm/CodeGen/MachineInstrBundle.h" using namespace llvm; +/// Return true if the given MachineOperand clobbers the given register unit. +/// A register unit is only clobbered if all its super-registers are clobbered. +static bool operClobbersUnit(const MachineOperand *MO, unsigned Unit, + const MCRegisterInfo *MCRI) { + for (MCRegUnitRootIterator RI(Unit, MCRI); RI.isValid(); ++RI) { + for (MCSuperRegIterator SI(*RI, MCRI, true); SI.isValid(); ++SI) { + if (!MO->clobbersPhysReg(*SI)) + return false; + } + } + return true; +} + /// We assume the high bits of a physical super register are not preserved /// unless the instruction has an implicit-use operand reading the /// super-register or a register unit for the upper bits is available. void LiveRegUnits::removeRegsInMask(const MachineOperand &Op, const MCRegisterInfo &MCRI) { - const uint32_t *Mask = Op.getRegMask(); - unsigned Bit = 0; - for (unsigned R = 0; R < MCRI.getNumRegs(); ++R) { - if ((*Mask & (1u << Bit)) == 0) - removeReg(R, MCRI); - ++Bit; - if (Bit >= 32) { - Bit = 0; - ++Mask; - } + SparseSet<unsigned>::iterator LUI = LiveUnits.begin(); + while (LUI != LiveUnits.end()) { + if (operClobbersUnit(&Op, *LUI, &MCRI)) + LUI = LiveUnits.erase(LUI); + else + ++LUI; } } |