[llvm-dev] Jump Threading duplicates dbg.declare intrinsics for fragments, bug?

Björn Steinbrink via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 19 05:27:54 PDT 2017


I'm hitting an assertion "overlapping or duplicate fragments" in the
DWARF codegen in addFragmentOffset(). This originates from a
duplicated dbg.declare intrinsic, declaring the same fragment twice.
The duplicated call was generated by the jump threading pass.

I have a patch (see below) that removes simply such duplicates, but
I'm not sure whether that is the right approach.


diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 499780a173b..308b6bd2b9f 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -220,6 +220,13 @@ ArrayRef<DbgVariable::FrameIndexExpr>
DbgVariable::getFrameIndexExprs() const {
               return A.Expr->getFragmentInfo()->OffsetInBits <
+  auto last = std::unique(FrameIndexExprs.begin(), FrameIndexExprs.end(),
+      [](const FrameIndexExpr &A, const FrameIndexExpr &B) -> bool {
+        return A.FI == B.FI && A.Expr == B.Expr;
+      });
+  FrameIndexExprs.erase(last, FrameIndexExprs.end());
   return FrameIndexExprs;

More information about the llvm-dev mailing list