Mikael Holmén
2011-Oct-12 08:30 UTC
[LLVMdev] Problem in TwoAddressInstructionPass::runOnMachineFunction regarding subRegs
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
Jakob Stoklund Olesen
2011-Oct-12 21:52 UTC
[LLVMdev] Problem in TwoAddressInstructionPass::runOnMachineFunction regarding subRegs
On Oct 12, 2011, at 1:30 AM, Mikael Holmén wrote:> 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?Normally, sub-register defs don't exist before TwoAddressInstructionPass. Everything is created using INSERT_SUBREG and REG_SEQUENCE. What does your code look like before TwoAddressInstructionPass? Is it in SSA form, or do you have multiple defs on a virtual register? The machine code verifier (-verify-machineinstrs) will check SSA form, but that feature is not in 2.9. /jakob
Seemingly Similar Threads
- Feature request: Determining source index of xapian-compact DatabaseError exception
- Two FPPassManager objects, and LocalStackSlotAllocation::runOnMachineFunction returns true but has not changed the data
- TwoAddressInstructionPass bug?
- TwoAddressInstructionPass bug?
- TwoAddressInstructionPass::isProfitableToConv3Addr()