-
- if (HaveNotEmitted) { // If the copy has not already been emitted, do it.
- assert(opVal.isVirtualRegister() &&
- "Machine PHI Operands must all be virtual registers!");
- unsigned SrcReg = opVal.getReg();
- RegInfo->copyRegToReg(opBlock, I, IncomingReg, SrcReg, RC);
-
- // Now update live variable information if we have it.
- if (LV) {
- // We want to be able to insert a kill of the register if this PHI
- // (aka, the copy we just inserted) is the last use of the source
- // value. Live variable analysis conservatively handles this by
- // saying that the value is live until the end of the block the PHI
- // entry lives in. If the value really is dead at the PHI copy, there
- // will be no successor blocks which have the value live-in.
- //
- // Check to see if the copy is the last use, and if so, update the
- // live variables information so that it knows the copy source
- // instruction kills the incoming value.
- //
- LiveVariables::VarInfo &InRegVI = LV->getVarInfo(SrcReg);
-
- // Loop over all of the successors of the basic block, checking to
- // see if the value is either live in the block, or if it is killed
- // in the block.
- //
- bool ValueIsLive = false;
- BasicBlock *BB = opBlock.getBasicBlock();
- for (succ_iterator SI = succ_begin(BB), E = succ_end(BB);
- SI != E; ++SI) {
- const std::pair<MachineBasicBlock*, unsigned> &
- SuccInfo = LV->getBasicBlockInfo(*SI);
-
- // Is it alive in this successor?
- unsigned SuccIdx = SuccInfo.second;
- if (SuccIdx < InRegVI.AliveBlocks.size() &&
- InRegVI.AliveBlocks[SuccIdx]) {
- ValueIsLive = true;
- break;
- }
-
- // Is it killed in this successor?
- MachineBasicBlock *MBB = SuccInfo.first;
- for (unsigned i = 0, e = InRegVI.Kills.size(); i != e; ++i)
- if (InRegVI.Kills[i].first == MBB) {
- ValueIsLive = true;
- break;
- }