Index: lib/CodeGen/LiveDebugVariables.cpp =================================================================== --- lib/CodeGen/LiveDebugVariables.cpp +++ lib/CodeGen/LiveDebugVariables.cpp @@ -675,13 +675,6 @@ // Don't track copies from physregs, it is too expensive. extendDef(Idx, LocNo, LR, VNI, nullptr, LIS, MDT, UVS); } - - // Finally, erase all the undefs. - for (LocMap::iterator I = locInts.begin(); I.valid();) - if (I.value() == ~0u) - I.erase(); - else - ++I; } void LDVImpl::computeIntervals() { @@ -928,15 +921,18 @@ LiveIntervals &LIS, const TargetInstrInfo &TII) { MachineBasicBlock::iterator I = findInsertLocation(MBB, Idx, LIS); - MachineOperand &Loc = locations[LocNo]; + MachineOperand *Loc = LocNo == ~0u ? nullptr : &locations[LocNo]; ++NumInsertedDebugValues; - if (Loc.isReg()) + if (!Loc) + BuildMI(*MBB, I, findDebugLoc(), TII.get(TargetOpcode::DBG_VALUE), + IsIndirect, 0, offset, variable); + else if (Loc->isReg()) BuildMI(*MBB, I, findDebugLoc(), TII.get(TargetOpcode::DBG_VALUE), - IsIndirect, Loc.getReg(), offset, variable); + IsIndirect, Loc->getReg(), offset, variable); else BuildMI(*MBB, I, findDebugLoc(), TII.get(TargetOpcode::DBG_VALUE)) - .addOperand(Loc).addImm(offset).addMetadata(variable); + .addOperand(*Loc).addImm(offset).addMetadata(variable); } void UserValue::emitDebugValues(VirtRegMap *VRM, LiveIntervals &LIS, Index: lib/Transforms/Scalar/SROA.cpp =================================================================== --- lib/Transforms/Scalar/SROA.cpp +++ lib/Transforms/Scalar/SROA.cpp @@ -874,24 +874,9 @@ for (SmallVectorImpl::const_iterator I = DVIs.begin(), E = DVIs.end(); I != E; ++I) { DbgValueInst *DVI = *I; - Value *Arg = nullptr; - if (StoreInst *SI = dyn_cast(Inst)) { - // If an argument is zero extended then use argument directly. The ZExt - // may be zapped by an optimization pass in future. - if (ZExtInst *ZExt = dyn_cast(SI->getOperand(0))) - Arg = dyn_cast(ZExt->getOperand(0)); - else if (SExtInst *SExt = dyn_cast(SI->getOperand(0))) - Arg = dyn_cast(SExt->getOperand(0)); - if (!Arg) - Arg = SI->getValueOperand(); - } else if (LoadInst *LI = dyn_cast(Inst)) { - Arg = LI->getPointerOperand(); - } else { - continue; - } - Instruction *DbgVal = - DIB.insertDbgValueIntrinsic(Arg, 0, DIVariable(DVI->getVariable()), - Inst); + Value *Arg = UndefValue::get(DVI->getValue()->getType()); + Instruction *DbgVal = DIB.insertDbgValueIntrinsic( + Arg, 0, DIVariable(DVI->getVariable()), Inst); DbgVal->setDebugLoc(DVI->getDebugLoc()); } }