From 6f3a6de0a7b1f720b702726179ddf3ddcdce1705 Mon Sep 17 00:00:00 2001
From: Jonas Paulsson <paulsson@linux.vnet.ibm.com>
Date: Mon, 16 Sep 2019 14:49:36 +0000
Subject: [PATCH] [SystemZ]  Call erase() on the right MBB in
 SystemZTargetLowering::emitSelect()

Since MBB was split *before* MI, the MI(s) will reside in JoinMBB (MBB) at
the point of erasing them, so calling StartMBB->erase() is actually wrong,
although it is "working" by all appearances.

Review: Ulrich Weigand

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371995 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Target/SystemZ/SystemZISelLowering.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Target/SystemZ/SystemZISelLowering.cpp b/lib/Target/SystemZ/SystemZISelLowering.cpp
index ce1582157e9..f79f40cc6c3 100644
--- a/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -6678,7 +6678,7 @@ SystemZTargetLowering::emitSelect(MachineInstr &MI,
       std::next(MachineBasicBlock::iterator(LastMI)), MBB->end());
   createPHIsForSelects(MIItBegin, MIItEnd, StartMBB, FalseMBB, MBB);
 
-  StartMBB->erase(MIItBegin, MIItEnd);
+  MBB->erase(MIItBegin, MIItEnd);
   return JoinMBB;
 }
 
-- 
2.40.0