[PATCH] D70642: [DebugInfo] Support for DW_OP_implicit_pointer (DW_OP_LLVM_argN)

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 4 17:00:45 PST 2019


aprantl added a comment.

In D70642#1769175 <https://reviews.llvm.org/D70642#1769175>, @alok wrote:

> In D70642#1767321 <https://reviews.llvm.org/D70642#1767321>, @aprantl wrote:
>
> > Thanks. This part looks good, but the bitcode upgrade is still missing.
>
>
> Sorry as I could not include that in first set of modifications. I was just thinking about which operations can be upgraded. One candidate for this was new expression DW_OP_LLVM_implicit_pointer which comes later that the current patch so escapes the need for upgrade. Should I look for existing operations for potential candidates for upgrade. or should i re-arrange the DW_OP_LLVM_implicit_pointer patch such as first it should not use DW_OP_LLVM_arg0 and then after current patch it needs upgrade. Could you please clear my doubt here ?


The upgrade I was thinking about here is reading old bitcode that contains

  llvm.dbg.value(%foo, DILocalVariable(...), DIExpression(DW_OP_deref))

and upgrades it to

  llvm.dbg.value(%foo, DILocalVariable(...), DIExpression(DW_OP_arg0, DW_OP_deref))

However, for this to work, we also need to implement support for DW_OP_argN to AsmPrinter to interpret the new operands and DIBuilder.

My assumption is that after this change `DIExpression()` is illegal and should be replaced by `DIExpression(DW_OP_LLVM_arg0)`.
This transformation will cause a lot of churn in the Clang and LLVM testsuite (most of which you will be able to fix with a a sed script), but it will allow to resolve the ambiguity between:

  !DIGlobalVariableExpression(!DIGlobalVariable("a"), !DIExpression())
  !DIGlobalVariableExpression(!DIGlobalVariable("a"), !DIExpression(DW_OP_constu 42, DW_OP_stack_value))
  !DIGlobalVariableExpression(!DIGlobalVariable("a"), !DIExpression(DW_OP_constu 42, DW_OP_plus, DW_OP_stack_value))

in the new scheme, these expressions would be

  !DIExpression(DW_OP_LLVM_arg0)
  !DIExpression(DW_OP_constu 42, DW_OP_stack_value) # constant, no arg!
  !DIExpression(DW_OP_LLVM_arg0, DW_OP_constu 42, DW_OP_plus, DW_OP_stack_value))

respectively. We currently disambiguate between these cases by context: if the `DIGlobalVariableExpression` is a `!dbg` attachment of an `llvm::Global`, the global is the implicit arg0, otherwise there is no implict argument.

Since this is going to be a lot of work, we could also opt for a smaller, incremental change first that introduces only `DW_OP_LLVM_arg1`..`DW_OP_LLVM_arg7` and keep the `DW_OP_LLVM_arg0` implicit. Then we don't need to worry about bitcode upgrades now.



================
Comment at: llvm/docs/LangRef.rst:4823
+  ``DW_OP_LLVM_arg0`` represents ``DILocalVariable("x")`` and
+  ``DW_OP_LLVM_arg1`` represents ``DILocalVariable("y")``.
 
----------------
I just realized that `DIGLobalVariableExpression` also takes a `DIExpression`. I think we should also allow DW_OP_LLVM_arg0 there.



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

https://reviews.llvm.org/D70642





More information about the llvm-commits mailing list