[llvm] r261016 - [codeview] Bail on a DBG_VALUE register operand with no register

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 16 13:49:27 PST 2016


Author: rnk
Date: Tue Feb 16 15:49:26 2016
New Revision: 261016

URL: http://llvm.org/viewvc/llvm-project?rev=261016&view=rev
Log:
[codeview] Bail on a DBG_VALUE register operand with no register

This apparently comes up when the register allocator decides that a
variable will become undef along a certain path.

Also improve the error message we emit when we can't map from LLVM
register number to CV register number.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
    llvm/trunk/lib/MC/MCRegisterInfo.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=261016&r1=261015&r2=261016&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Tue Feb 16 15:49:26 2016
@@ -594,11 +594,13 @@ void CodeViewDebug::collectVariableInfo(
       if (DIExpr && DIExpr->getNumElements() > 0)
         continue;
 
-      // Bail if the value is not indirect in memory or in a register. In these
-      // cases, operand 0 will not be a register.
-      // FIXME: CodeView does not have an obvious representation for a variable
-      // that has been optimized to be a constant.
-      if (!DVInst->getOperand(0).isReg())
+      // Bail if operand 0 is not a valid register. This means the variable is a
+      // simple constant, or is described by a complex expression.
+      // FIXME: Find a way to represent constant variables, since they are
+      // relatively common.
+      unsigned Reg =
+          DVInst->getOperand(0).isReg() ? DVInst->getOperand(0).getReg() : 0;
+      if (Reg == 0)
         continue;
 
       // Handle the two cases we can handle: indirect in memory and in register.

Modified: llvm/trunk/lib/MC/MCRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCRegisterInfo.cpp?rev=261016&r1=261015&r2=261016&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCRegisterInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCRegisterInfo.cpp Tue Feb 16 15:49:26 2016
@@ -86,8 +86,10 @@ int MCRegisterInfo::getSEHRegNum(unsigne
 }
 
 int MCRegisterInfo::getCodeViewRegNum(unsigned RegNum) const {
+  if (L2CVRegs.empty())
+    report_fatal_error("target does not implement codeview register mapping");
   const DenseMap<unsigned, int>::const_iterator I = L2CVRegs.find(RegNum);
   if (I == L2CVRegs.end())
-    report_fatal_error("target does not implement codeview register mapping");
+    report_fatal_error("unknown codeview register");
   return I->second;
 }




More information about the llvm-commits mailing list