diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp index 4c16ae70d1f3..26c2a20dea19 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp @@ -93,6 +93,12 @@ void DwarfExpression::AddMachineRegPiece(unsigned MachineReg, unsigned PieceSizeInBits, unsigned PieceOffsetInBits) { const TargetRegisterInfo *TRI = getTRI(); + if (!TRI->isPhysicalRegister(MachineReg)) { + // FIXME: We have no reasonable way of handling errors in here. + EmitOp(dwarf::DW_OP_nop, "nop (could not find a dwarf register number)"); + return; + } + int Reg = TRI->getDwarfRegNum(MachineReg, false); // If this is a valid register number, emit it.