[PATCH] D53756: [Mips] Conditionally remove successor block

Stefan Maksimovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 26 05:56:07 PDT 2018


smaksimovic created this revision.
smaksimovic added a reviewer: atanasyan.
Herald added subscribers: arichardson, sdardis.

In MipsBranchExpansion::splitMBB, upon splitting a block with two direct branches,
remove the successor of the newly created block (which inherits successors from the
original block) which is pointed to by the last branch in the original block only if
the targets of two branches differ.

This is to fix the failing test when ran with -verify-machineinstrs enabled.


https://reviews.llvm.org/D53756

Files:
  lib/Target/Mips/MipsBranchExpansion.cpp
  test/CodeGen/Mips/micromips-mtc-mfc.ll


Index: test/CodeGen/Mips/micromips-mtc-mfc.ll
===================================================================
--- test/CodeGen/Mips/micromips-mtc-mfc.ll
+++ test/CodeGen/Mips/micromips-mtc-mfc.ll
@@ -1,7 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=mips -mcpu=mips32r2 -mattr=+micromips \
+; RUN: llc -mtriple=mips -mcpu=mips32r2 -mattr=+micromips -verify-machineinstrs \
 ; RUN:     -show-mc-encoding < %s | FileCheck --check-prefix=MM2 %s
-; RUN: llc -mtriple=mips -mcpu=mips32r6 -mattr=+micromips \
+; RUN: llc -mtriple=mips -mcpu=mips32r6 -mattr=+micromips -verify-machineinstrs \
 ; RUN:     -show-mc-encoding < %s | FileCheck --check-prefix=MM6 %s
 
 define double @foo(double %a, double %b) {
Index: lib/Target/Mips/MipsBranchExpansion.cpp
===================================================================
--- lib/Target/Mips/MipsBranchExpansion.cpp
+++ lib/Target/Mips/MipsBranchExpansion.cpp
@@ -271,7 +271,8 @@
   // Insert NewMBB and fix control flow.
   MachineBasicBlock *Tgt = getTargetMBB(*FirstBr);
   NewMBB->transferSuccessors(MBB);
-  NewMBB->removeSuccessor(Tgt, true);
+  if (Tgt != getTargetMBB(*LastBr))
+    NewMBB->removeSuccessor(Tgt, true);
   MBB->addSuccessor(NewMBB);
   MBB->addSuccessor(Tgt);
   MFp->insert(std::next(MachineFunction::iterator(MBB)), NewMBB);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53756.171288.patch
Type: text/x-patch
Size: 1361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181026/18e50328/attachment.bin>


More information about the llvm-commits mailing list