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

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 14 12:28:15 PST 2019


aprantl added a comment.

In D56587#1356420 <https://reviews.llvm.org/D56587#1356420>, @markus wrote:

> In D56587#1356258 <https://reviews.llvm.org/D56587#1356258>, @aprantl wrote:
>
> > Referencing a DIE in DIExpression would need a bit of additional work. DIExpression stores its operands in an array of uint64_t, so in order to support MDNode operands we'd have to add them as actual MDNode operands. For example, `expr_op_iterator` could know which DIExpression operations take MDNode arguments and inject them in the right places. Slightly more complicated would be actually finding a matching DIType in the debug info that we want to point to. If we want to convert to exactly the type of the DIVariable, we can use that type, otherwise we might have to generate new DIBasicTypes on the fly.
> >
> > Even though this sounds complicated, I still think that it is preferable to encode type conversions as such rather than generating really complicated expressions that happen to have the same effect in the underspecified DWARF 4 stack language.
>
>
> Yes, long term it is likely the best solution.
>
> I played a bit with trying to insert a DW_OP_convert before I came up with this patch but was clueless on how to retrieve the DIE offset of the DIType when the expression was emitted as that section (.debug_info?) hadn't been emitted yet. If I could get some useful advice on tackling that issue I can have another go at it when I get back to work tomorrow.


You wouldn't hardcode the offset in IR, you'd refer to the DIType as an MDNode reference and then teach the backend to resolve the reference, similar to how DIE references are resolved in the entire DIType class hierarchy.

In LLVM Assembly this could look like:

  !1 = !DIBasicType(name: "short", ...)
  !2 = !DIExpression(DW_OP_convert, !1)

but the actual implementation would be as I outlined in my previous reply.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D56587





More information about the llvm-commits mailing list