[PATCH] D79306: llvm rejects DWARF operator DW_OP_push_object_address.

Alok Kumar Sharma via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 5 01:34:36 PDT 2020


alok added a comment.

In D79306#2018097 <https://reviews.llvm.org/D79306#2018097>, @aprantl wrote:

> Can you explain in more detail how flang is going to use this? In LLVM DIExpressions expressions we currently never refer to the SSA values that are bound to the expression via a dbg.value/dbg.declare from within the expression. We've had discussions about how to do this in the past (see https://reviews.llvm.org/D70642 and the discussions preceding it) and I would like to make sure that this fits well into the design.
>
> It would be particularly helpful if you could post example LLVM IR that would be produced by flang to make use of this feature and the DWARF that should be generated from it.


I apologies as the testcase I added is a little misleading. Please treat that as a meaning less test case just to check whether the operator is accepted in DIExpression. I dont plan to use the DW_OP_push_object_address inside dbg.value/dbg.addr/dbg.declare. Instead I plan to use it in Bounds (lowerBound, upperBound or count, stride) of DISubrange (in DWARF).

Let me explain how I plan to use it for allocatable arrays.

Fortran allocatable arrays have bound information in array descriptor, which can be accessed using certain offsets. I plan to generate IR something like below.

. . . . . .  . . . . . . . 
!11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, size: 32, align: 32, elements: !13)
!13 = !{!14}
!14 = !DIFortranSubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 80, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 120, DW_OP_deref), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 112, DW_OP_deref, DW_OP_plus_uconst, 4, DW_OP_mul))
. . . . . . . . . . . . . .

which would be translated to DWARF as

. . . . . . . . . . .
0x0000004d:       DW_TAG_variable

  DW_AT_location      (DW_OP_fbreg +168)
  DW_AT_name  ("arr")
  DW_AT_type  (0x00000065 "integer[]")

0x00000065:   DW_TAG_array_type

  DW_AT_type      (0x00000086 "integer")

0x0000006e:     DW_TAG_subrange_type

  DW_AT_type    (0x0000008d "__ARRAY_SIZE_TYPE__")
  DW_AT_lower_bound     (DW_OP_push_object_address, DW_OP_plus_uconst 0x50, DW_OP_deref)
  DW_AT_upper_bound     (DW_OP_push_object_address, DW_OP_plus_uconst 0x78, DW_OP_deref)
  DW_AT_byte_stride     (DW_OP_push_object_address, DW_OP_plus_uconst 0x70, DW_OP_deref, DW_OP_plus_uconst 0x4, DW_OP_mul)

. . . . . . . . . . .

Here DW_OP_push_object_address refers to the value of the DW_AT_location of DW_TAG_variable.

Please let me know if you need more details ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79306





More information about the llvm-commits mailing list