[llvm] [MachineOutliner] Efficient Implementation of MachineOutliner::findCandidates() (PR #90260)

Gai Liu via llvm-commits llvm-commits at lists.llvm.org
Tue May 14 18:33:14 PDT 2024


================
@@ -593,7 +593,11 @@ void MachineOutliner::findCandidates(
     unsigned NumDiscarded = 0;
     unsigned NumKept = 0;
 #endif
-    for (const unsigned &StartIdx : RS.StartIndices) {
+    // Sort the start indices so that we can efficiently check if candidates
+    // overlap with each other in MachineOutliner::findCandidates().
+    SmallVector<unsigned> SortedStartIndices(RS.StartIndices);
----------------
gl387 wrote:

Why do we need to make a copy here? Can we directly sort RS.StartIndices?

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


More information about the llvm-commits mailing list