diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index f0256ae..7d26e7e 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -10438,7 +10438,6 @@ dbx_reg_number (const_rtx rtl)
 #endif
 
   regno = DBX_REGISTER_NUMBER (regno);
-  gcc_assert (regno != INVALID_REGNUM);
   return regno;
 }
 
@@ -10473,6 +10472,9 @@ reg_loc_descriptor (rtx rtl, enum var_init_status initialized)
   if (REGNO (rtl) >= FIRST_PSEUDO_REGISTER)
     return 0;
 
+  if (dbx_reg_number(rtl) == INVALID_REGNUM)
+    return 0;
+
   /* We only use "frame base" when we're sure we're talking about the
      post-prologue local stack frame.  We do this by *not* running
      register elimination until this point, and recognizing the special
@@ -11931,6 +11933,8 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
 	    break;
 	  if (REGNO (rtl) > FIRST_PSEUDO_REGISTER)
 	    break;
+	  if (dbx_reg_number (rtl) == INVALID_REGNUM)
+	    break;
 	  type_die = base_type_for_mode (mode,
 					 GET_MODE_CLASS (mode) == MODE_INT);
 	  if (type_die == NULL)
@@ -12133,6 +12137,9 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
 	return NULL;
       if (REG_P (ENTRY_VALUE_EXP (rtl)))
 	{
+	  if (dbx_reg_number (ENTRY_VALUE_EXP (rtl)) == INVALID_REGNUM)
+	    return NULL;
+
 	  if (GET_MODE_CLASS (mode) != MODE_INT
 	      || GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE)
 	    op0 = mem_loc_descriptor (ENTRY_VALUE_EXP (rtl), mode,
