Skip to content

Commit c343b4c

Browse files
committed
Approved by Evan:
$ svn merge -c 113299 https://llvm.org/svn/llvm-project/llvm/trunk --- Merging r113299 into '.': U lib/CodeGen/VirtRegRewriter.cpp llvm-svn: 113531
1 parent 68d848b commit c343b4c

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

llvm/lib/CodeGen/VirtRegRewriter.cpp

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,16 @@ VirtRegRewriter::~VirtRegRewriter() {}
6767
/// Note that operands may be added, so the MO reference is no longer valid.
6868
static void substitutePhysReg(MachineOperand &MO, unsigned Reg,
6969
const TargetRegisterInfo &TRI) {
70-
if (unsigned SubIdx = MO.getSubReg()) {
71-
// Insert the physical subreg and reset the subreg field.
72-
MO.setReg(TRI.getSubReg(Reg, SubIdx));
73-
MO.setSubReg(0);
74-
75-
// Any def, dead, and kill flags apply to the full virtual register, so they
76-
// also apply to the full physical register. Add imp-def/dead and imp-kill
77-
// as needed.
70+
if (MO.getSubReg()) {
71+
MO.substPhysReg(Reg, TRI);
72+
73+
// Any kill flags apply to the full virtual register, so they also apply to
74+
// the full physical register.
75+
// We assume that partial defs have already been decorated with a super-reg
76+
// <imp-def> operand by LiveIntervals.
7877
MachineInstr &MI = *MO.getParent();
79-
if (MO.isDef())
80-
if (MO.isDead())
81-
MI.addRegisterDead(Reg, &TRI, /*AddIfNotFound=*/ true);
82-
else
83-
MI.addRegisterDefined(Reg, &TRI);
84-
else if (!MO.isUndef() &&
85-
(MO.isKill() ||
86-
MI.isRegTiedToDefOperand(&MO-&MI.getOperand(0))))
78+
if (MO.isUse() && !MO.isUndef() &&
79+
(MO.isKill() || MI.isRegTiedToDefOperand(&MO-&MI.getOperand(0))))
8780
MI.addRegisterKilled(Reg, &TRI, /*AddIfNotFound=*/ true);
8881
} else {
8982
MO.setReg(Reg);

0 commit comments

Comments
 (0)