From ff608a7a691af31a0cd0413993c0d3aa8c4e7de4 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Wed, 15 Nov 2006 20:56:03 +0000 Subject: [PATCH] commuteInstruction should propagate kill / dead info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31763 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/TargetInstrInfo.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/Target/TargetInstrInfo.cpp b/lib/Target/TargetInstrInfo.cpp index d28f1e7c505..cc637ed4063 100644 --- a/lib/Target/TargetInstrInfo.cpp +++ b/lib/Target/TargetInstrInfo.cpp @@ -60,7 +60,17 @@ MachineInstr *TargetInstrInfo::commuteInstruction(MachineInstr *MI) const { "This only knows how to commute register operands so far"); unsigned Reg1 = MI->getOperand(1).getReg(); unsigned Reg2 = MI->getOperand(2).getReg(); + bool Reg1IsKill = MI->getOperand(1).isKill(); + bool Reg2IsKill = MI->getOperand(2).isKill(); MI->getOperand(2).setReg(Reg1); MI->getOperand(1).setReg(Reg2); + if (Reg1IsKill) + MI->getOperand(2).setIsKill(); + else + MI->getOperand(2).unsetIsKill(); + if (Reg2IsKill) + MI->getOperand(1).setIsKill(); + else + MI->getOperand(1).unsetIsKill(); return MI; } -- 2.34.1