[PATCH] D20147: [WIP] DebugInfo: New metadata representation for global variables.

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Wed May 11 10:30:53 PDT 2016


aprantl added a comment.

In http://reviews.llvm.org/D20147#427453, @pcc wrote:

> > Instead of baking a byte-offset into the IR, I was more thinking of using the DIExpression to describe the offset:
>
>
> I suppose we could do that, but I reckon that would make things more complicated:
>
> - each constant would need two DIExpressions, one for the case where a global exists and an address can be derived from the attached GlobalVariable's address, and one for the case where the global has been optimized away (where we'd use DW_OP_stack_value to describe the constant)


Not sure if I follow. While the constant still exists as a global in the IR, the DIExpression would be empty.
Whenever a constant is deleted from IR, we invoke a utility that

- adds the DIGlobalVariable to the DICompileUnit to retain it
- translates the constexpr into a DIExpression

This is assuming that after GlobalMerge happened no merged globals will be removed.

> - it would add complexity to the `copyMetadata` function, as it would need to be able to manipulate and rewrite DIExpressions


Can you give a quick example for this?

> - I also plan to use the offset in other kinds of metadata attached to globals, such as the type metadata for CFI and vtable opt. If we use a separate representation for each kind of metadata, `copyMetadata` would need to know how to adjust the offset in each kind of metadata





http://reviews.llvm.org/D20147





More information about the llvm-commits mailing list