From 286fed5c8ced2ee642ed6e3b97a7bdd6d929937c Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Fri, 27 Jan 2012 00:05:42 +0000 Subject: Rewrite instruction operands in AdjustCopiesBackFrom. Fixes PR11861. llvm-svn: 149097 --- llvm/lib/CodeGen/RegisterCoalescer.cpp | 10 ++++++---- llvm/test/CodeGen/ARM/2012-01-26-CoalescerBug.ll | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 llvm/test/CodeGen/ARM/2012-01-26-CoalescerBug.ll (limited to 'llvm') diff --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp b/llvm/lib/CodeGen/RegisterCoalescer.cpp index 3493645f7f2..b7d18ba1a14 100644 --- a/llvm/lib/CodeGen/RegisterCoalescer.cpp +++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp @@ -553,10 +553,12 @@ bool RegisterCoalescer::AdjustCopiesBackFrom(const CoalescerPair &CP, if (UIdx != -1) { ValLREndInst->getOperand(UIdx).setIsKill(false); } - - // If the copy instruction was killing the destination register before the - // merge, find the last use and trim the live range. That will also add the - // isKill marker. + + // Rewrite the copy. If the copy instruction was killing the destination + // register before the merge, find the last use and trim the live range. That + // will also add the isKill marker. + CopyMI->substituteRegister(IntA.reg, IntB.reg, CP.getSubIdx(), + *TRI); if (ALR->end == CopyIdx) LIS->shrinkToUses(&IntA); diff --git a/llvm/test/CodeGen/ARM/2012-01-26-CoalescerBug.ll b/llvm/test/CodeGen/ARM/2012-01-26-CoalescerBug.ll new file mode 100644 index 00000000000..ec5b2e9de7c --- /dev/null +++ b/llvm/test/CodeGen/ARM/2012-01-26-CoalescerBug.ll @@ -0,0 +1,21 @@ +; RUN: llc < %s -verify-coalescing +; PR11861 +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32-S64" +target triple = "armv7-none-linux-eabi" + +define arm_aapcs_vfpcc void @foo() nounwind uwtable align 2 { + br label %1 + +;