diff options
-rw-r--r-- | llvm/include/llvm/CodeGen/MachineOutliner.h | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineOutliner.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 4 |
3 files changed, 13 insertions, 1 deletions
diff --git a/llvm/include/llvm/CodeGen/MachineOutliner.h b/llvm/include/llvm/CodeGen/MachineOutliner.h index 5aa0382ce7b..4249a99a891 100644 --- a/llvm/include/llvm/CodeGen/MachineOutliner.h +++ b/llvm/include/llvm/CodeGen/MachineOutliner.h @@ -217,6 +217,8 @@ public: for (std::shared_ptr<Candidate> &C : Candidates) C->Benefit = B; } + + OutlinedFunction() {} }; } // namespace outliner } // namespace llvm diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp index 1babe4239e5..28e4e2c6c87 100644 --- a/llvm/lib/CodeGen/MachineOutliner.cpp +++ b/llvm/lib/CodeGen/MachineOutliner.cpp @@ -979,7 +979,13 @@ unsigned MachineOutliner::findCandidates( // We've found something we might want to outline. // Create an OutlinedFunction to store it and check if it'd be beneficial // to outline. - OutlinedFunction OF = TII.getOutliningCandidateInfo(CandidatesForRepeatedSeq); + OutlinedFunction OF = + TII.getOutliningCandidateInfo(CandidatesForRepeatedSeq); + + // If we deleted every candidate, then there's nothing to outline. + if (OF.Candidates.empty()) + continue; + std::vector<unsigned> Seq; for (unsigned i = Leaf->SuffixIdx; i < Leaf->SuffixIdx + StringLen; i++) Seq.push_back(ST.Str[i]); diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index dc3fa4f8c1d..230480cf1ce 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -4967,6 +4967,10 @@ AArch64InstrInfo::getOutliningCandidateInfo( CantGuaranteeValueAcrossCall), RepeatedSequenceLocs.end()); + // If the sequence is empty, we're done. + if (RepeatedSequenceLocs.empty()) + return outliner::OutlinedFunction(); + // At this point, we have only "safe" candidates to outline. Figure out // frame + call instruction information. |