]> granicus.if.org Git - llvm/commitdiff
Assert that the offset of a DBG_VALUE is always 0. (NFC)
authorAdrian Prantl <aprantl@apple.com>
Wed, 2 Aug 2017 17:19:13 +0000 (17:19 +0000)
committerAdrian Prantl <aprantl@apple.com>
Wed, 2 Aug 2017 17:19:13 +0000 (17:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309834 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.cpp

index 8820d21dd14d1fb5db8a98196b35428a9468f8ef..3b73c2a07b0328fc1ce35c8c2b985dfbfd922bc3 100644 (file)
@@ -481,9 +481,11 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
   if (const MachineInstr *DVInsn = DV.getMInsn()) {
     assert(DVInsn->getNumOperands() == 4);
     if (DVInsn->getOperand(0).isReg()) {
-      const MachineOperand RegOp = DVInsn->getOperand(0);
+      auto RegOp = DVInsn->getOperand(0);
+      auto Op1 = DVInsn->getOperand(1);
       // If the second operand is an immediate, this is an indirect value.
-      MachineLocation Location(RegOp.getReg(), DVInsn->getOperand(1).isImm());
+      assert((!Op1.isImm() || (Op1.getImm() == 0)) && "unexpected offset");
+      MachineLocation Location(RegOp.getReg(), Op1.isImm());
       addVariableAddress(DV, *VariableDie, Location);
     } else if (DVInsn->getOperand(0).isImm()) {
       // This variable is described by a single constant.
index b4bd470fe85a637ccfb58d9a7afa61f3960bb7eb..e44af1978a6f4eff37c60224da0aacebc20a0eb8 100644 (file)
@@ -828,12 +828,14 @@ void DwarfDebug::collectVariableInfoFromMFTable(
 // Get .debug_loc entry for the instruction range starting at MI.
 static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) {
   const DIExpression *Expr = MI->getDebugExpression();
-
   assert(MI->getNumOperands() == 4);
   if (MI->getOperand(0).isReg()) {
+    auto RegOp = MI->getOperand(0);
+    auto Op1 = MI->getOperand(1);
     // If the second operand is an immediate, this is a
     // register-indirect address.
-    MachineLocation MLoc(MI->getOperand(0).getReg(), MI->getOperand(1).isImm());
+    assert((!Op1.isImm() || (Op1.getImm() == 0)) && "unexpected offset");
+    MachineLocation MLoc(RegOp.getReg(), Op1.isImm());
     return DebugLocEntry::Value(Expr, MLoc);
   }
   if (MI->getOperand(0).isImm())