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

Kyungwoo Lee via llvm-commits llvm-commits at lists.llvm.org
Thu May 23 08:00:46 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);
----------------
kyulee-com wrote:

I think it's a good suggestion. Can you simply drop `const` in the outer loop so that you can sort them in place?

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


More information about the llvm-commits mailing list