[PATCH] D84112: [DebugInfo] Support for DW_OP_implicit_pointer for named and unnamed variables (second strategy).

Alok Kumar Sharma via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 18 16:21:36 PDT 2020


alok created this revision.
alok added a reviewer: dblaikie.
alok added a project: debug-info.
Herald added subscribers: llvm-commits, asbirlea, ormris, mgrang, hiraditya, aprantl.
Herald added a reviewer: jdoerfert.
Herald added a project: LLVM.

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).
I shall split this patch into multiple patches shortly.

  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)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84112

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/BinaryFormat/Dwarf.h
  llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h
  llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
  llvm/include/llvm/CodeGen/MachineInstr.h
  llvm/include/llvm/CodeGen/MachineInstrBuilder.h
  llvm/include/llvm/CodeGen/SelectionDAG.h
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/include/llvm/IR/Instruction.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/IR/Value.h
  llvm/include/llvm/Transforms/Scalar/SROA.h
  llvm/include/llvm/Transforms/Utils/Local.h
  llvm/lib/BinaryFormat/Dwarf.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
  llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
  llvm/lib/CodeGen/LiveDebugValues.cpp
  llvm/lib/CodeGen/MachineInstr.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
  llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
  llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/Instruction.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/IR/Metadata.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/IR/Value.cpp
  llvm/lib/Transforms/InstCombine/InstCombineInternal.h
  llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Scalar/BDCE.cpp
  llvm/lib/Transforms/Scalar/DCE.cpp
  llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
  llvm/lib/Transforms/Scalar/EarlyCSE.cpp
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/lib/Transforms/Scalar/LICM.cpp
  llvm/lib/Transforms/Scalar/Reassociate.cpp
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
  llvm/test/DebugInfo/X86/LLVM_explicit_pointer.ll
  llvm/test/DebugInfo/X86/LLVM_implicit_pointer.ll
  llvm/test/DebugInfo/X86/dwarfdump-implicit_pointer_instcomb.c
  llvm/test/DebugInfo/X86/dwarfdump-implicit_pointer_instcomb.ll
  llvm/test/DebugInfo/X86/dwarfdump-implicit_pointer_mem2reg.c
  llvm/test/DebugInfo/X86/dwarfdump-implicit_pointer_mem2reg.ll
  llvm/test/DebugInfo/X86/dwarfdump-implicit_pointer_sroa.c
  llvm/test/DebugInfo/X86/dwarfdump-implicit_pointer_sroa.ll
  llvm/test/DebugInfo/X86/dwarfdump-implicit_pointer_sroa_inline.c
  llvm/test/DebugInfo/X86/dwarfdump-implicit_pointer_sroa_inline.ll
  llvm/test/DebugInfo/X86/implicit_pointer_fast.ll
  llvm/test/DebugInfo/X86/implicit_pointer_global.ll
  llvm/test/DebugInfo/X86/implicit_pointer_instcomb.c
  llvm/test/DebugInfo/X86/implicit_pointer_mem2reg.c
  llvm/test/DebugInfo/X86/implicit_pointer_promote2reg.c
  llvm/test/DebugInfo/X86/implicit_pointer_sroa.c
  llvm/test/DebugInfo/X86/implicit_pointer_sroa_inline.c
  llvm/test/DebugInfo/X86/implicit_pointer_temp_dyn_alloc.cc
  llvm/test/DebugInfo/X86/implicit_pointer_temp_reference.cc
  llvm/unittests/IR/DebugInfoTest.cpp
  llvm/unittests/Transforms/Utils/LocalTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84112.279033.patch
Type: text/x-patch
Size: 158989 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200718/a33a9a60/attachment-0001.bin>


More information about the llvm-commits mailing list