diff options
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstrBundle.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstrBundle.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineInstrBundle.cpp b/llvm/lib/CodeGen/MachineInstrBundle.cpp index 4da0184..d9e8484 100644 --- a/llvm/lib/CodeGen/MachineInstrBundle.cpp +++ b/llvm/lib/CodeGen/MachineInstrBundle.cpp @@ -94,6 +94,22 @@ static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, return DebugLoc(); } +/// Check if target reg is contained in given lists, which are: +/// LocalDefsV as given list for virtual regs +/// LocalDefsP as given list for physical regs, in BitVector[RegUnit] form +static bool containsReg(SmallSetVector<Register, 32> LocalDefsV, + const BitVector &LocalDefsP, Register Reg, + const TargetRegisterInfo *TRI) { + if (Reg.isPhysical()) { + for (MCRegUnit Unit : TRI->regunits(Reg.asMCReg())) + if (!LocalDefsP[Unit]) + return false; + + return true; + } + return LocalDefsV.contains(Reg); +} + /// finalizeBundle - Finalize a machine instruction bundle which includes /// a sequence of instructions starting from FirstMI to LastMI (exclusive). /// This routine adds a BUNDLE instruction to represent the bundle, it adds @@ -115,6 +131,7 @@ void llvm::finalizeBundle(MachineBasicBlock &MBB, Bundle.prepend(MIB); SmallSetVector<Register, 32> LocalDefs; + BitVector LocalDefsP(TRI->getNumRegUnits()); SmallSet<Register, 8> DeadDefSet; SmallSet<Register, 16> KilledDefSet; SmallSetVector<Register, 8> ExternUses; @@ -130,7 +147,7 @@ void llvm::finalizeBundle(MachineBasicBlock &MBB, if (!Reg) continue; - if (LocalDefs.contains(Reg)) { + if (containsReg(LocalDefs, LocalDefsP, Reg, TRI)) { MO.setIsInternalRead(); if (MO.isKill()) { // Internal def is now killed. @@ -165,8 +182,10 @@ void llvm::finalizeBundle(MachineBasicBlock &MBB, } } - if (!MO.isDead() && Reg.isPhysical()) - LocalDefs.insert_range(TRI->subregs(Reg)); + if (!MO.isDead() && Reg.isPhysical()) { + for (MCRegUnit Unit : TRI->regunits(Reg.asMCReg())) + LocalDefsP.set(Unit); + } } // Set FrameSetup/FrameDestroy for the bundle. If any of the instructions |