summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorJessica Paquette <jpaquette@apple.com>2018-11-13 23:01:34 +0000
committerJessica Paquette <jpaquette@apple.com>2018-11-13 23:01:34 +0000
commitcad864d49e90b95de39d62f71fb6d1b7172b7498 (patch)
treeec5e8277c3cb1137e9008e44625fa019bafdd028 /llvm/lib/Target
parent9039b6012e2c18416aad0edae548c28159e12f8a (diff)
downloadbcm5719-llvm-cad864d49e90b95de39d62f71fb6d1b7172b7498.tar.gz
bcm5719-llvm-cad864d49e90b95de39d62f71fb6d1b7172b7498.zip
[MachineOutliner][NFC] Use MBB flags to avoid call checks in getOutliningInfo
We already determine a bunch of information about an MBB in getMachineOutlinerMBBFlags. We can reuse that information to avoid calculating things that must be false/true. The first thing we can easily check is if an outlined sequence could ever contain calls. There's no reason to walk over the outlined range, checking for calls, if we already know that there are no calls in the block containing the sequence. llvm-svn: 346809
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/AArch64/AArch64InstrInfo.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index 176514dd361..219dd4ddf5a 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -5128,12 +5128,12 @@ AArch64InstrInfo::findRegisterToSaveLRTo(const outliner::Candidate &C) const {
outliner::OutlinedFunction
AArch64InstrInfo::getOutliningCandidateInfo(
std::vector<outliner::Candidate> &RepeatedSequenceLocs) const {
- unsigned SequenceSize = std::accumulate(
- RepeatedSequenceLocs[0].front(),
- std::next(RepeatedSequenceLocs[0].back()),
- 0, [this](unsigned Sum, const MachineInstr &MI) {
- return Sum + getInstSizeInBytes(MI);
- });
+ outliner::Candidate &FirstCand = RepeatedSequenceLocs[0];
+ unsigned SequenceSize =
+ std::accumulate(FirstCand.front(), std::next(FirstCand.back()), 0,
+ [this](unsigned Sum, const MachineInstr &MI) {
+ return Sum + getInstSizeInBytes(MI);
+ });
// Compute liveness information for each candidate.
const TargetRegisterInfo &TRI = getRegisterInfo();
@@ -5240,21 +5240,25 @@ AArch64InstrInfo::getOutliningCandidateInfo(
}
}
- // Check if the range contains a call. These require a save + restore of the
- // link register.
- if (std::any_of(RepeatedSequenceLocs[0].front(),
- RepeatedSequenceLocs[0].back(),
- [](const MachineInstr &MI) { return MI.isCall(); }))
- NumBytesToCreateFrame += 8; // Save + restore the link register.
-
- // Handle the last instruction separately. If this is a tail call, then the
- // last instruction is a call. We don't want to save + restore in this case.
- // However, it could be possible that the last instruction is a call without
- // it being valid to tail call this sequence. We should consider this as well.
- else if (FrameID != MachineOutlinerThunk &&
- FrameID != MachineOutlinerTailCall &&
- RepeatedSequenceLocs[0].back()->isCall())
- NumBytesToCreateFrame += 8;
+ // If the MBB containing the first candidate has calls, then it's possible
+ // that we have calls in the candidate. If there are no calls, then there's
+ // no way that any candidate could have any calls.
+ if (FirstCand.Flags & MachineOutlinerMBBFlags::HasCalls) {
+ // Check if the range contains a call. These require a save + restore of the
+ // link register.
+ if (std::any_of(FirstCand.front(), FirstCand.back(),
+ [](const MachineInstr &MI) { return MI.isCall(); }))
+ NumBytesToCreateFrame += 8; // Save + restore the link register.
+
+ // Handle the last instruction separately. If this is a tail call, then the
+ // last instruction is a call. We don't want to save + restore in this case.
+ // However, it could be possible that the last instruction is a call without
+ // it being valid to tail call this sequence. We should consider this as
+ // well.
+ else if (FrameID != MachineOutlinerThunk &&
+ FrameID != MachineOutlinerTailCall && FirstCand.back()->isCall())
+ NumBytesToCreateFrame += 8;
+ }
return outliner::OutlinedFunction(RepeatedSequenceLocs, SequenceSize,
NumBytesToCreateFrame, FrameID);
OpenPOWER on IntegriCloud