[llvm] [Codegen] (NFC) Faster algorithm for MachineBlockPlacement (PR #91843)

William Junda Huang via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 16:10:17 PDT 2024


================
@@ -3118,7 +3158,22 @@ bool MachineBlockPlacement::maybeTailDuplicateBlock(
 
         // Handle the filter set
         if (BlockFilter) {
-          BlockFilter->remove(RemBB);
+          auto It = llvm::find(*BlockFilter, RemBB);
+          // Erase RemBB from BlockFilter, and keep PrevUnplacedBlockInFilterIt
+          // pointing to the same element as before.
+          if (It != BlockFilter->end()) {
+            if (It < PrevUnplacedBlockInFilterIt) {
+              // BlockFilter is a SmallVector so all elements after RemBB are
+              // shifted to the front by 1 after its deletion.
+              auto Distance = PrevUnplacedBlockInFilterIt - It - 1;
----------------
huangjd wrote:

Done.

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


More information about the llvm-commits mailing list