1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[MachineOutliner][NFC] Simplify isMBBSafeToOutlineFrom check in AArch64 outliner

Turns out it's way simpler to do this check with one LRU. Instead of
maintaining two, just keep one. Check if each of the registers is available,
and then check if it's a live out from the block. If it's a live out, but
available in the block, we know we're in an unsafe case.

llvm-svn: 346721
This commit is contained in:
Jessica Paquette 2018-11-13 00:32:09 +00:00
parent c3c414d7b1
commit 184774cd2c

View File

@ -5292,26 +5292,26 @@ bool AArch64InstrInfo::isMBBSafeToOutlineFrom(MachineBasicBlock &MBB,
// a flag. // a flag.
assert(MBB.getParent()->getRegInfo().tracksLiveness() && assert(MBB.getParent()->getRegInfo().tracksLiveness() &&
"Suitable Machine Function for outlining must track liveness"); "Suitable Machine Function for outlining must track liveness");
LiveRegUnits ModifiedRegUnits(getRegisterInfo()); LiveRegUnits LRU(getRegisterInfo());
LiveRegUnits UsedRegUnits(getRegisterInfo());
ModifiedRegUnits.addLiveOuts(MBB);
UsedRegUnits.addLiveOuts(MBB);
const TargetRegisterInfo *TRI = &getRegisterInfo();
std::for_each(MBB.rbegin(), MBB.rend(), std::for_each(MBB.rbegin(), MBB.rend(),
[&ModifiedRegUnits, &UsedRegUnits, &TRI](MachineInstr &MI) { [&LRU](MachineInstr &MI) { LRU.accumulate(MI); });
LiveRegUnits::accumulateUsedDefed(MI, ModifiedRegUnits,
UsedRegUnits, TRI);
});
// If one of these registers is live out of the MBB, but not modified in the // Check if each of the unsafe registers are available...
// MBB, then we can't outline. bool W16AvailableInBlock = LRU.available(AArch64::W16);
if ((ModifiedRegUnits.available(AArch64::W16) && bool W17AvailableInBlock = LRU.available(AArch64::W17);
!UsedRegUnits.available(AArch64::W16)) || bool NZCVAvailableInBlock = LRU.available(AArch64::NZCV);
(ModifiedRegUnits.available(AArch64::W17) &&
!UsedRegUnits.available(AArch64::W17)) || // Now, add the live outs to the set.
(ModifiedRegUnits.available(AArch64::NZCV) && LRU.addLiveOuts(MBB);
!UsedRegUnits.available(AArch64::NZCV)))
// If any of these registers is available in the MBB, but also a live out of
// the block, then we know outlining is unsafe.
if (W16AvailableInBlock && !LRU.available(AArch64::W16))
return false;
if (W17AvailableInBlock && !LRU.available(AArch64::W17))
return false;
if (NZCVAvailableInBlock && !LRU.available(AArch64::NZCV))
return false; return false;
// Check if there's a call inside this MachineBasicBlock. If there is, then // Check if there's a call inside this MachineBasicBlock. If there is, then
@ -5319,8 +5319,7 @@ bool AArch64InstrInfo::isMBBSafeToOutlineFrom(MachineBasicBlock &MBB,
if (any_of(MBB, [](MachineInstr &MI) { return MI.isCall(); })) if (any_of(MBB, [](MachineInstr &MI) { return MI.isCall(); }))
Flags |= MachineOutlinerMBBFlags::HasCalls; Flags |= MachineOutlinerMBBFlags::HasCalls;
if (!ModifiedRegUnits.available(AArch64::LR) || if (!LRU.available(AArch64::LR))
!UsedRegUnits.available(AArch64::LR))
Flags |= MachineOutlinerMBBFlags::LRUnavailableSomewhere; Flags |= MachineOutlinerMBBFlags::LRUnavailableSomewhere;
return true; return true;