[llvm] [RISCV] [MachineOutliner] Analyze all candidates (PR #127659)

Sam Elliott via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 18 20:51:09 PST 2025


================
@@ -3047,35 +3042,32 @@ RISCVInstrInfo::getOutliningCandidateInfo(
     std::vector<outliner::Candidate> &RepeatedSequenceLocs,
     unsigned MinRepeats) const {
 
-  // Each RepeatedSequenceLoc is identical.
-  outliner::Candidate &Candidate = RepeatedSequenceLocs[0];
-  auto CandidateInfo = analyzeCandidate(Candidate);
-  if (!CandidateInfo)
-    RepeatedSequenceLocs.clear();
+  // Analyze each candidate and erase the ones that are not viable.
+  llvm::erase_if(RepeatedSequenceLocs, analyzeCandidate);
 
   // If the sequence doesn't have enough candidates left, then we're done.
   if (RepeatedSequenceLocs.size() < MinRepeats)
     return std::nullopt;
 
+  // Each RepeatedSequenceLoc is identical.
+  outliner::Candidate &Candidate = RepeatedSequenceLocs[0];
   unsigned InstrSizeCExt =
       Candidate.getMF()->getSubtarget<RISCVSubtarget>().hasStdExtCOrZca() ? 2
                                                                           : 4;
----------------
lenary wrote:

Let's leave this to a follow-up patch.

I think we do have to care a little about which call we can use because the call instruction will not show up in the candidate sequence (which is a bit different to what's pointed out in that comment).

https://github.com/llvm/llvm-project/pull/127659


More information about the llvm-commits mailing list