[PATCH] D38918: Update successor after branch relaxation in ARM

Sameer AbuAsal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 13 19:00:54 PDT 2017


sabuasal created this revision.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.

While relaxing branches in ARM constant Island we might need to split
the basic block the branch instruction belongs to.

The splitBlockBeforeInstr API transfers the successors to the new block
including the destination block of the machine instruction. Later on
a branch is added from the Basic Block to the destination block
without adding the destination block as a successor. This patch fixes
that.


Repository:
  rL LLVM

https://reviews.llvm.org/D38918

Files:
  lib/Target/ARM/ARMConstantIslandPass.cpp


Index: lib/Target/ARM/ARMConstantIslandPass.cpp
===================================================================
--- lib/Target/ARM/ARMConstantIslandPass.cpp
+++ lib/Target/ARM/ARMConstantIslandPass.cpp
@@ -1713,6 +1713,13 @@
   unsigned MaxDisp = getUnconditionalBrDisp(Br.UncondBr);
   ImmBranches.push_back(ImmBranch(&MBB->back(), MaxDisp, false, Br.UncondBr));

+  if (NeedSplit) {
+    // When we split the MBB we transferred all its successors to the newly
+    // created block so the DestBB is no longer marked as a predecessor. Add
+    // it back here.
+    MBB->addSuccessor(DestBB);
+  }
+
   // Remove the old conditional branch.  It may or may not still be in MBB.
   BBInfo[MI->getParent()->getNumber()].Size -= TII->getInstSizeInBytes(*MI);
   MI->eraseFromParent();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38918.119007.patch
Type: text/x-patch
Size: 786 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171014/73ac6959/attachment.bin>


More information about the llvm-commits mailing list