[DebugInfo] Don't use DW_OP_implicit_value for fragments
authorPavel Labath <pavel@labath.sk>
Tue, 24 Nov 2020 09:24:29 +0000 (10:24 +0100)
committerPavel Labath <pavel@labath.sk>
Tue, 22 Dec 2020 09:07:47 +0000 (10:07 +0100)
commit8d75d902a955602feb7e2501e34f814ff5630415
tree29ea849188f56eb40e25692688a942539326c01b
parent0a8a2453fb843cf2e0f43e389b58d516525f0b8c
[DebugInfo] Don't use DW_OP_implicit_value for fragments

Currently using DW_OP_implicit_value in fragments produces invalid DWARF
expressions. (Such a case can occur in complex floats, for example.)

This problem manifests itself as a missing DW_OP_piece operation after
the last fragment. This happens because the function for printing
constant float value skips printing the accompanying DWARF expression,
as that would also print DW_OP_stack_value (which is not desirable in
this case). However, this also results in DW_OP_piece being skipped.

The reason that DW_OP_piece is missing only for the last piece is that
the act of printing the next fragment corrects this. However, it does
that for the wrong reason -- the code emitting this DW_OP_piece thinks
that the previous fragment was missing, and so it thinks that it needs
to skip over it in order to be able to print itself.

In a simple scenario this works out, but it's likely that in a more
complex setup (where some pieces are in fact missing), this logic would
go badly wrong. In a simple setup gdb also seems to not mind the fact
that the DW_OP_piece is missing, but it would also likely not handle
more complex use cases.

For this reason, this patch disables the usage of DW_OP_implicit_value
in the frament scenario (we will use DW_OP_const*** instead), until we
figure out the right way to deal with this. This guarantees that we
produce valid expressions, and gdb can handle both kinds of inputs
anyway.

Differential Revision: https://reviews.llvm.org/D92013
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/test/DebugInfo/X86/implicit_value-double.ll