Stop undef fragments from closing non-overlapping fragments
authorDavid Stenberg <david.stenberg@ericsson.com>
Tue, 28 May 2019 13:23:25 +0000 (13:23 +0000)
committerDavid Stenberg <david.stenberg@ericsson.com>
Tue, 28 May 2019 13:23:25 +0000 (13:23 +0000)
commit5d0e6b6755da38084809d38bf527164a7f285ecd
tree0603f89dc3768a237a91e34d25b63a4158abb4ae
parentd3ed418ad3c4bd233b926e586888e177d4fa82be
Stop undef fragments from closing non-overlapping fragments

Summary:
When DwarfDebug::buildLocationList() encountered an undef debug value,
it would truncate all open values, regardless if they were overlapping or
not. This patch fixes so that it only does that for overlapping fragments.

This change unearthed a bug that I had introduced in D57511,
which I have fixed in this patch. The code in DebugHandlerBase that
changes labels for parameter debug values could break DwarfDebug's
assumption that the labels for the entries in the debug value history
are monotonically increasing. Before this patch, that bug could result
in location list entries whose ending address was lower than the
beginning address, and with the changes for undef debug values that this
patch introduces it could trigger an assertion, due to attempting to
emit location list entries with empty ranges. A reproducer for the bug
is added in param-reg-const-mix.mir.

Reviewers: aprantl, jmorse, probinson

Reviewed By: aprantl

Subscribers: javed.absar, llvm-commits

Tags: #debug-info, #llvm

Differential Revision: https://reviews.llvm.org/D62379

llvm-svn: 361820
llvm/include/llvm/CodeGen/MachineInstr.h
llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/test/DebugInfo/MIR/ARM/param-reg-const-mix.mir [new file with mode: 0644]
llvm/test/DebugInfo/X86/undef-fragment.ll [new file with mode: 0644]