From 000ef2c2ae0752ae97a99db8dabada7ca2f480f3 Mon Sep 17 00:00:00 2001 From: Amara Emerson Date: Tue, 2 Jul 2019 06:04:46 +0000 Subject: [TailDuplicator] Fix copy instruction emitting into the wrong block. The code for duplicating instructions could sometimes try to emit copies intended to deal with unconstrainable register classes to the tail block of the original instruction, rather than before the newly cloned instruction in the predecessor block. This was exposed by GlobalISel on arm64. Differential Revision: https://reviews.llvm.org/D64049 llvm-svn: 364888 --- llvm/lib/CodeGen/TailDuplicator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/TailDuplicator.cpp') diff --git a/llvm/lib/CodeGen/TailDuplicator.cpp b/llvm/lib/CodeGen/TailDuplicator.cpp index 4d3e02e3174..a0590a8a6cc 100644 --- a/llvm/lib/CodeGen/TailDuplicator.cpp +++ b/llvm/lib/CodeGen/TailDuplicator.cpp @@ -434,7 +434,7 @@ void TailDuplicator::duplicateInstruction( if (NewRC == nullptr) NewRC = OrigRC; unsigned NewReg = MRI->createVirtualRegister(NewRC); - BuildMI(*PredBB, MI, MI->getDebugLoc(), + BuildMI(*PredBB, NewMI, NewMI.getDebugLoc(), TII->get(TargetOpcode::COPY), NewReg) .addReg(VI->second.Reg, 0, VI->second.SubReg); LocalVRMap.erase(VI); -- cgit v1.2.3