[PATCH] D56587: Fix sign/zero extension in Dwarf expressions.

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 1 07:48:25 PST 2019


aprantl added a comment.

Generally, I much prefer using DW_OP_convert because it's more space efficient and semantically unambiguous.

I have a couple of unsorted ideas:

> call void @llvm.dbg.value(metadata i8 %x, metadata !15, metadata !DIExpression(DW_OP_convert, 0, DW_OP_convert, 1, DW_OP_stack_value)),

the type reference should be a metadata operand. Otherwise you'll need to implement support in llvm-link etc, too.
I would just implement the type reference as normal metadata operands in DIExpression and bake the knowledge that DW_OP_convert consumes one of the metadata operands into the DIExpression operand iterator.

MDNodes are uniqued, so just creating a new DIBasicType using a throwaway DIBuilder is cheap. That said, we need to find the types references by DIExpressions so they can be emitted in the .debug_info section.

On the other extreme, the only thing we really need from the basic types used by DW_OP_convert is the size and signedness. We could just encode that directly in the expression as DW_OP_LLVM_convert, 1, 32 for a signed int32_t or something like that. That doesn't solve the problem for how to determine which types we need to emit into the debug info, but it would be a very straightforward self-contained encoding up until AsmPrinter.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56587/new/

https://reviews.llvm.org/D56587





More information about the llvm-commits mailing list