summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorJessica Paquette <jpaquette@apple.com>2018-11-12 23:51:32 +0000
committerJessica Paquette <jpaquette@apple.com>2018-11-12 23:51:32 +0000
commit82d9c0a3fabda486a646a4749c6534790d970ca6 (patch)
treee4f78a526f27a0a706e33a6edd214464dbdbdbe0 /llvm/lib/Target
parente9f34b0d521f96669217656fa8162336a7d3f00a (diff)
downloadbcm5719-llvm-82d9c0a3fabda486a646a4749c6534790d970ca6.tar.gz
bcm5719-llvm-82d9c0a3fabda486a646a4749c6534790d970ca6.zip
[MachineOutliner][NFC] Change getMachineOutlinerMBBFlags to isMBBSafeToOutlineFrom
Instead of returning Flags, return true if the MBB is safe to outline from. This lets us check for unsafe situations, like say, in AArch64, X17 is live across a MBB without being defined in that MBB. In that case, there's no point in performing an instruction mapping. llvm-svn: 346718
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/AArch64/AArch64InstrInfo.cpp47
-rw-r--r--llvm/lib/Target/AArch64/AArch64InstrInfo.h3
2 files changed, 33 insertions, 17 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index bcf278e7888..71cbffdff48 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -5286,29 +5286,44 @@ bool AArch64InstrInfo::isFunctionSafeToOutlineFrom(
return true;
}
-unsigned
-AArch64InstrInfo::getMachineOutlinerMBBFlags(MachineBasicBlock &MBB) const {
- unsigned Flags = 0x0;
- // Check if there's a call inside this MachineBasicBlock. If there is, then
- // set a flag.
- if (any_of(MBB, [](MachineInstr &MI) { return MI.isCall(); }))
- Flags |= MachineOutlinerMBBFlags::HasCalls;
-
+bool AArch64InstrInfo::isMBBSafeToOutlineFrom(MachineBasicBlock &MBB,
+ unsigned &Flags) const {
// Check if LR is available through all of the MBB. If it's not, then set
// a flag.
assert(MBB.getParent()->getRegInfo().tracksLiveness() &&
"Suitable Machine Function for outlining must track liveness");
- LiveRegUnits LRU(getRegisterInfo());
- LRU.addLiveOuts(MBB);
+ LiveRegUnits ModifiedRegUnits(getRegisterInfo());
+ LiveRegUnits UsedRegUnits(getRegisterInfo());
+ ModifiedRegUnits.addLiveOuts(MBB);
+ UsedRegUnits.addLiveOuts(MBB);
+ const TargetRegisterInfo *TRI = &getRegisterInfo();
- std::for_each(MBB.rbegin(),
- MBB.rend(),
- [&LRU](MachineInstr &MI) { LRU.accumulate(MI); });
+ 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)))
+ return false;
- if (!LRU.available(AArch64::LR))
- Flags |= MachineOutlinerMBBFlags::LRUnavailableSomewhere;
+ // Check if there's a call inside this MachineBasicBlock. If there is, then
+ // set a flag.
+ if (any_of(MBB, [](MachineInstr &MI) { return MI.isCall(); }))
+ Flags |= MachineOutlinerMBBFlags::HasCalls;
+
+ if (!ModifiedRegUnits.available(AArch64::LR) ||
+ !UsedRegUnits.available(AArch64::LR))
+ Flags |= MachineOutlinerMBBFlags::LRUnavailableSomewhere;
- return Flags;
+ return true;
}
outliner::InstrType
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.h b/llvm/lib/Target/AArch64/AArch64InstrInfo.h
index 43011dd4c3e..404d632b13c 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.h
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.h
@@ -246,7 +246,8 @@ public:
std::vector<outliner::Candidate> &RepeatedSequenceLocs) const override;
outliner::InstrType
getOutliningType(MachineBasicBlock::iterator &MIT, unsigned Flags) const override;
- unsigned getMachineOutlinerMBBFlags(MachineBasicBlock &MBB) const override;
+ bool isMBBSafeToOutlineFrom(MachineBasicBlock &MBB,
+ unsigned &Flags) const override;
void buildOutlinedFrame(MachineBasicBlock &MBB, MachineFunction &MF,
const outliner::OutlinedFunction &OF) const override;
MachineBasicBlock::iterator
OpenPOWER on IntegriCloud