[llvm] [BranchRelaxation] Remove quadratic behavior in relaxation pass (PR #96250)

Mingming Liu via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 25 17:27:12 PDT 2024


================
@@ -590,7 +604,7 @@ bool BranchRelaxation::fixupUnconditionalBranch(MachineInstr &MI) {
                             RS.get());
 
   BlockInfo[BranchBB->getNumber()].Size = computeBlockSize(*BranchBB);
-  adjustBlockOffsets(*MBB);
+  adjustBlockOffsets(*MBB, std::next(BranchBB->getIterator()));
 
----------------
minglotus-6 wrote:

My reading of the surrounding code block is that, before fixing up unconditional branch, there is `MBB -> DestBB`, and before this call that it becomes `MBB -> BranchBB -> DestBB -> RestoreBB`, and this line essentially just run `adjustBlockOffsets` for one MBB (the `BranchBB`) even if a range is specified.

I'd suggest add a comment like `create block offsets for newly-created BranchBB` to call out the MBBs adjusted.

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


More information about the llvm-commits mailing list