Skip to content
This repository has been archived by the owner on Jan 9, 2021. It is now read-only.

Commit

Permalink
Added assertion in getVRegDef of MachineRegisterInfo to make sure the…
Browse files Browse the repository at this point in the history
… virtual

register does not have multiple definitions. Modified TwoAddressInstructionPass
to use getUniqueVRegDef instead of getVRegDef.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159545 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Manman Ren committed Jul 2, 2012
1 parent 49589f0 commit 5f917cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/CodeGen/MachineRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ void MachineRegisterInfo::replaceRegWith(unsigned FromReg, unsigned ToReg) {
MachineInstr *MachineRegisterInfo::getVRegDef(unsigned Reg) const {
// Since we are in SSA form, we can use the first definition.
def_iterator I = def_begin(Reg);
assert((I.atEnd() || llvm::next(I) == def_end()) &&
"getVRegDef assumes a single definition or no definition");
return !I.atEnd() ? &*I : 0;
}

Expand Down
11 changes: 6 additions & 5 deletions lib/CodeGen/TwoAddressInstructionPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
// Emit a copy or rematerialize the definition.
bool isCopy = false;
const TargetRegisterClass *rc = MRI->getRegClass(regB);
MachineInstr *DefMI = MRI->getVRegDef(regB);
MachineInstr *DefMI = MRI->getUniqueVRegDef(regB);
// If it's safe and profitable, remat the definition instead of
// copying it.
if (DefMI &&
Expand Down Expand Up @@ -1722,9 +1722,10 @@ TwoAddressInstructionPass::CoalesceExtSubRegs(SmallVector<unsigned,4> &Srcs,
continue;

// Check that the instructions are all in the same basic block.
MachineInstr *SrcDefMI = MRI->getVRegDef(SrcReg);
MachineInstr *DstDefMI = MRI->getVRegDef(DstReg);
if (SrcDefMI->getParent() != DstDefMI->getParent())
MachineInstr *SrcDefMI = MRI->getUniqueVRegDef(SrcReg);
MachineInstr *DstDefMI = MRI->getUniqueVRegDef(DstReg);
if (!SrcDefMI || !DstDefMI ||
SrcDefMI->getParent() != DstDefMI->getParent())
continue;

// If there are no other uses than copies which feed into
Expand Down Expand Up @@ -1874,7 +1875,7 @@ bool TwoAddressInstructionPass::EliminateRegSequences() {
MachineInstr *DefMI = NULL;
if (!MI->getOperand(i).getSubReg() &&
!TargetRegisterInfo::isPhysicalRegister(SrcReg)) {
DefMI = MRI->getVRegDef(SrcReg);
DefMI = MRI->getUniqueVRegDef(SrcReg);
}

if (DefMI && DefMI->isImplicitDef()) {
Expand Down

0 comments on commit 5f917cd

Please sign in to comment.