diff options
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 72e5870..dc4b1a6 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -1131,15 +1131,24 @@ auto MachineFunction::salvageCopySSA(MachineInstr &MI) } } + MachineBasicBlock &InsertBB = *CurInst->getParent(); + // We reached the start of the block before finding a defining instruction. - // It must be an argument: assert that this is the entry block, and produce - // a DBG_PHI. - assert(!State.first.isVirtual()); - MachineBasicBlock &TargetBB = *CurInst->getParent(); - assert(&*TargetBB.getParent()->begin() == &TargetBB); + // It could be from a constant register, otherwise it must be an argument. + if (TRI.isConstantPhysReg(State.first)) { + // We can produce a DBG_PHI that identifies the constant physreg. Doesn't + // matter where we put it, as it's constant valued. + assert(CurInst->isCopy()); + } else { + // Assert that this is the entry block. If it isn't, then there is some + // code construct we don't recognise that deals with physregs across + // blocks. + assert(!State.first.isVirtual()); + assert(&*InsertBB.getParent()->begin() == &InsertBB); + } // Create DBG_PHI for specified physreg. - auto Builder = BuildMI(TargetBB, TargetBB.getFirstNonPHI(), DebugLoc(), + auto Builder = BuildMI(InsertBB, InsertBB.getFirstNonPHI(), DebugLoc(), TII.get(TargetOpcode::DBG_PHI)); Builder.addReg(State.first, RegState::Debug); unsigned NewNum = getNewDebugInstrNum(); |