There was a missing check for if a candidate list was entirely deleted. This
adds that check.
This fixes an asan failure caused by running test/CodeGen/AArch64/addsub_ext.ll
with the MachineOutliner enabled.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338148
91177308-0d34-0410-b5e6-
96231b3b80d8
for (std::shared_ptr<Candidate> &C : Candidates)
C->Benefit = B;
}
+
+ OutlinedFunction() {}
};
} // namespace outliner
} // namespace llvm
// 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]);
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.