This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Support for DW_OP_implicit_pointer for named and unnamed variables (second strategy).
Needs ReviewPublic

Authored by alok on Jul 18 2020, 4:21 PM.

Details

Summary

This is to support DWARF5 operator DW_OP_implicit_pointer, which was earlier attempted but had some objections from reviewers. This second strategy includes suggestion from David. @dblaikie please provide your views on this (design wise).
It is split into 8 separate patches for better understanding.
D84113, D84114, D84115, D84116, D84117, D84118, D84119, D84120

Example:
    c program lines--
      int var1 = 4;
      int arr[2] = {9, 10};
      int *ptr1 = &var1;
      int *ptr2 = arr;
      int ptrPtr1 = &ptr1;
      int ptrPtr2 = &ptr2;

    It'll be converted to below IR--

      call void @llvm.dbg.value(metadata i32 4, metadata !DILocalVariable(name: "ptr1"), metadata !DIExpression(DW_OP_LLVM_explicit_pointer))
      call void @llvm.dbg.value(metadata i32 9, metadata !DILocalVariable(name: "ptr2"), metadata !DIExpression(DW_OP_LLVM_explicit_pointer))
      call void @llvm.dbg.value(metadata i32 4, metadata !DILocalVariable(name: "ptrPtr1"), metadata !DIExpression(DW_OP_LLVM_explicit_pointer,DW_OP_LLVM_explicit_pointer))
      call void @llvm.dbg.value(metadata i32 9, metadata !DILocalVariable(name: "ptrPtr2"), metadata !DIExpression(DW_OP_LLVM_explicit_pointer,DW_OP_LLVM_explicit_pointer))

     In DWARF, DW_OP_LLVM_explicit_pointer will be converted to DW_OP_implicit_pointer using temporary variables

0x0000009c:     DW_TAG_variable
                  DW_AT_location        (indexed (0x8) loclist = 0x000000aa:
                     [0x0000000000201667, 0x0000000000201674): DW_OP_implicit_pointer 0xa5 +0)
                  DW_AT_name    ("ptrptr1")
0x000000a5:     DW_TAG_variable
                  DW_AT_location        (indexed (0x9) loclist = 0x000000b5:
                     [0x0000000000201667, 0x0000000000201674): DW_OP_implicit_pointer 0xac +0)
                  DW_AT_name    ("__implicit_ptr_tmp_4")
                  DW_AT_artificial      (true)
0x000000ac:     DW_TAG_variable
                  DW_AT_location        (indexed (0xa) loclist = 0x000000c0:
                     [0x0000000000201667, 0x0000000000201674): DW_OP_lit4, DW_OP_stack_value)
                  DW_AT_name    ("__implicit_ptr_tmp_3")
                  DW_AT_artificial      (true)

Testing:
  • Added unit tests for validation thru llvm-dwarfdump
  • check-llvm, and an end-to-end test using gnu GDB to debug an optimized program (LLDB need to be enhanced to support).
  • check-debuginfo (the debug info integration tests)

Diff Detail

Event Timeline

alok created this revision.Jul 18 2020, 4:21 PM
Herald added a project: Restricted Project. · View Herald Transcript

Could you include a link to the original discussion (I have no recollection of what I might've said on the subject... ) & also link to the other code reviews sent based on this one.

And/or it might be best to continue the discussion on the original design discussion thread (assuming that's where this was discussed - if it was discussed in another code review, maybe having a separate llvm-dev design thread would be suitable), with this as an aid, rather than to start reviewing this or the other.

alok edited the summary of this revision. (Show Details)Jul 20 2020, 10:43 PM
ormris removed a subscriber: ormris.Jun 3 2021, 11:02 AM