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)