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

Xuan Zhang via llvm-commits llvm-commits at lists.llvm.org
Tue May 28 13:48:48 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);
----------------
xuanzh-meta wrote:

I dropped the `const` and sort the `RS.StartIndices` in place. 

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


More information about the llvm-commits mailing list