[LLVMdev] Problem in TwoAddressInstructionPass::runOnMachineFunction regarding subRegs
Mikael Holmén
mikael.holmen at ericsson.com
Wed Oct 12 01:30:08 PDT 2011
Hi,
It seems to me that the TwoAddressInstructionPass::runOnMachineFunction
method has some problems when the tied destination register has a subReg.
The two changes below improves the situation for me but I'm all new to
this so I'm not sure how it's supposed to work. I'm running on 2.9.
Any comments?
@@ -1172,12 +1172,20 @@ bool
TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
unsigned regASubIdx = mi->getOperand(DstIdx).getSubReg();
TII->reMaterialize(*mbbi, mi, regA, regASubIdx, DefMI, *TRI);
ReMatRegs.set(TargetRegisterInfo::virtReg2Index(regB));
++NumReMats;
} else {
- BuildMI(*mbbi, mi, mi->getDebugLoc(),
TII->get(TargetOpcode::COPY),
- regA).addReg(regB);
+ unsigned regASubIdx = mi->getOperand(DstIdx).getSubReg();
+ if (regASubIdx) {
+ BuildMI(*mbbi, mi, mi->getDebugLoc(),
+ TII->get(TargetOpcode::COPY)).
+ addReg(regA, RegState::Define, regASubIdx).addReg(regB);
+ }
+ else {
+ BuildMI(*mbbi, mi, mi->getDebugLoc(),
+ TII->get(TargetOpcode::COPY), regA).addReg(regB);
+ }
}
MachineBasicBlock::iterator prevMI = prior(mi);
// Update DistanceMap.
DistanceMap.insert(std::make_pair(prevMI, Dist));
@@ -1190,11 +1198,13 @@ bool
TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
"inconsistent operand info for 2-reg pass");
if (MO.isKill()) {
MO.setIsKill(false);
RemovedKillFlag = true;
}
+ unsigned regASubIdx = mi->getOperand(DstIdx).getSubReg();
MO.setReg(regA);
+ MO.setSubReg(regASubIdx);
}
/Mikael Holmén
More information about the llvm-dev
mailing list