summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
diff options
context:
space:
mode:
authorJessica Paquette <jpaquette@apple.com>2018-11-13 00:32:09 +0000
committerJessica Paquette <jpaquette@apple.com>2018-11-13 00:32:09 +0000
commit106946329d579ec1036a511e3770a8f9f84a4a82 (patch)
treed2fafc877560d455e6a719bcb57a98d7569b6f7b /llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
parentcc633af55b74eac4e5a6c49cc6a7af7b7a3fe283 (diff)
downloadbcm5719-llvm-106946329d579ec1036a511e3770a8f9f84a4a82.tar.gz
bcm5719-llvm-106946329d579ec1036a511e3770a8f9f84a4a82.zip
[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
Diffstat (limited to 'llvm/lib/Target/AArch64/AArch64InstrInfo.cpp')
-rw-r--r--llvm/lib/Target/AArch64/AArch64InstrInfo.cpp39
1 files changed, 19 insertions, 20 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index 71cbffdff48..436a6f11817 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -5292,26 +5292,26 @@ bool AArch64InstrInfo::isMBBSafeToOutlineFrom(MachineBasicBlock &MBB,
// a flag.
assert(MBB.getParent()->getRegInfo().tracksLiveness() &&
"Suitable Machine Function for outlining must track liveness");
- LiveRegUnits ModifiedRegUnits(getRegisterInfo());
- LiveRegUnits UsedRegUnits(getRegisterInfo());
- ModifiedRegUnits.addLiveOuts(MBB);
- UsedRegUnits.addLiveOuts(MBB);
- const TargetRegisterInfo *TRI = &getRegisterInfo();
+ LiveRegUnits LRU(getRegisterInfo());
std::for_each(MBB.rbegin(), MBB.rend(),
- [&ModifiedRegUnits, &UsedRegUnits, &TRI](MachineInstr &MI) {
- LiveRegUnits::accumulateUsedDefed(MI, ModifiedRegUnits,
- UsedRegUnits, TRI);
- });
-
- // If one of these registers is live out of the MBB, but not modified in the
- // MBB, then we can't outline.
- if ((ModifiedRegUnits.available(AArch64::W16) &&
- !UsedRegUnits.available(AArch64::W16)) ||
- (ModifiedRegUnits.available(AArch64::W17) &&
- !UsedRegUnits.available(AArch64::W17)) ||
- (ModifiedRegUnits.available(AArch64::NZCV) &&
- !UsedRegUnits.available(AArch64::NZCV)))
+ [&LRU](MachineInstr &MI) { LRU.accumulate(MI); });
+
+ // Check if each of the unsafe registers are available...
+ bool W16AvailableInBlock = LRU.available(AArch64::W16);
+ bool W17AvailableInBlock = LRU.available(AArch64::W17);
+ bool NZCVAvailableInBlock = LRU.available(AArch64::NZCV);
+
+ // Now, add the live outs to the set.
+ LRU.addLiveOuts(MBB);
+
+ // 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;
// 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(); }))
Flags |= MachineOutlinerMBBFlags::HasCalls;
- if (!ModifiedRegUnits.available(AArch64::LR) ||
- !UsedRegUnits.available(AArch64::LR))
+ if (!LRU.available(AArch64::LR))
Flags |= MachineOutlinerMBBFlags::LRUnavailableSomewhere;
return true;
OpenPOWER on IntegriCloud