Index: llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h =================================================================== --- llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h +++ llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h @@ -77,6 +77,9 @@ /// Is ODR marking done? bool ODRMarkingDone : 1; + + /// Is DIE a forward or backward reference? + bool Reference : 1; }; CompileUnit(DWARFUnit &OrigUnit, unsigned ID, bool CanUseODR, Index: llvm/lib/DWARFLinker/DWARFLinker.cpp =================================================================== --- llvm/lib/DWARFLinker/DWARFLinker.cpp +++ llvm/lib/DWARFLinker/DWARFLinker.cpp @@ -934,9 +934,9 @@ } if (!RefInfo.Clone) { - assert(Ref > InputDIE.getOffset()); // We haven't cloned this DIE yet. Just create an empty one and // store it. It'll get really cloned when we process it. + RefInfo.Reference = true; RefInfo.Clone = DIE::get(DIEAlloc, dwarf::Tag(RefDie.getTag())); } NewRefDie = RefInfo.Clone; @@ -949,7 +949,7 @@ // FIXME: we should be able to design DIEEntry reliance on // DwarfDebug away. uint64_t Attr; - if (Ref < InputDIE.getOffset()) { + if (Ref < InputDIE.getOffset() && !RefInfo.Reference) { // We must have already cloned that DIE. uint32_t NewRefOffset = RefUnit->getStartOffset() + NewRefDie->getOffset();