Reinstantiate old/bad deduplication logic that was removed in r315279.
authorDaniel Jasper <djasper@google.com>
Thu, 12 Oct 2017 13:25:05 +0000 (13:25 +0000)
committerDaniel Jasper <djasper@google.com>
Thu, 12 Oct 2017 13:25:05 +0000 (13:25 +0000)
While this shouldn't be necessary anymore, we have cases where we run
into the assertion below, i.e. cases with two non-fragment entries for the
same variable at different frame indices.

This should be fixed, but for now, we should revert to a version that
does not trigger asserts.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315576 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfDebug.cpp

index 4844d68172be73faa5b1b71cb0178d70c1815775..048a284ade51423144594a92ce3de78b2c789d78 100644 (file)
@@ -233,6 +233,16 @@ void DbgVariable::addMMIEntry(const DbgVariable &V) {
   assert(!FrameIndexExprs.empty() && "Expected an MMI entry");
   assert(!V.FrameIndexExprs.empty() && "Expected an MMI entry");
 
+  // FIXME: This logic should not be necessary anymore, as we now have proper
+  // deduplication. However, without it, we currently run into the assertion
+  // below, which means that we are likely dealing with broken input, i.e. two
+  // non-fragment entries for the same variable at different frame indices.
+  if (FrameIndexExprs.size()) {
+    auto *Expr = FrameIndexExprs.back().Expr;
+    if (!Expr || !Expr->isFragment())
+      return;
+  }
+
   for (const auto &FIE : V.FrameIndexExprs)
     // Ignore duplicate entries.
     if (llvm::none_of(FrameIndexExprs, [&](const FrameIndexExpr &Other) {