[llvm] [Codegen] (NFC) Faster algorithm for MachineBlockPlacement (PR #91843)
David Li via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 12 21:30:53 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;
----------------
david-xl wrote:
Add a debug assert that what PrevUnplacedBlockFilterIt points to the same block before after after the removal for the first case?
https://github.com/llvm/llvm-project/pull/91843
More information about the llvm-commits
mailing list