Debug line entry tables are generated from .loc directives in the assembly. .loc directives should be generated for function prologues when a prologue is generated. They should be omitted when a prologue is stripped.
The current behaviour of the DwarfDebug ASMPrinter is to print a .loc directive for a prologue, missing or otherwise if a function has user code.
As a result, a .loc directive was being emitted for prologue code that had been stripped.
This lead to illegal DWARF line entries being generated, where the first instruction of a function with a stripped prologue being mapped to two lines of source line - the function opening brace and the first line of user code.
This patch implements a fix that checks for prologue code and avoids emitting .loc directives when it's not found.
I've also written a regression test that aims to force the backend to generate functions in assembly with missing prologues and checks that .loc directives are missing for stripped prologues.
This patch has been tested on Linux Ubuntu (VM) to elf and Windows 10 to exe, targetting x86_64 architectures.
I've also run a before and after with the LLDB and GDB test suites and found no new failing tests.
I'd probably swap this around for an early return: