This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi, I noticed that when you generate dwarf for an inlined function it often comes with duplicate range lists for both the DW_TAG_inlined_subroutine and the child DW_TAG_lexical_block DIE. For example: static int k; static int foo (int i) { int j = i + 42; return k + (j > 14 ? j : i); } int main (int argc, char **argv) { int c = argc; k = 2 * c; c = foo (c); return c; } Generates with -O2 -gdwarf-4: DWARF section [27] '.debug_info' at offset 0x895: [Offset] Compilation unit at offset 0: Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4 [...] [ a8] inlined_subroutine abstract_origin (ref4) [ 31] entry_pc (addr) 0x0000000000400360 <main> ranges (data4) range list [ 0] call_file (data1) 1 call_line (data1) 13 [ bb] formal_parameter abstract_origin (ref4) [ 42] location (block1) [ 0] reg5 [ c2] lexical_block ranges (data4) range list [ 40] [ c7] variable abstract_origin (ref4) [ 4b] location (data4) location list [ 23] [...] DWARF section [32] '.debug_ranges' at offset 0xb4e: [ 0] 0x0000000000400360 <main>..0x0000000000400363 <main+0x3> 0x0000000000400366 <main+0x6>..0x0000000000400369 <main+0x9> 0x000000000040036f <main+0xf>..0x0000000000400374 <main+0x14> [ 40] 0x0000000000400360 <main>..0x0000000000400363 <main+0x3> 0x0000000000400366 <main+0x6>..0x0000000000400369 <main+0x9> 0x000000000040036f <main+0xf>..0x0000000000400374 <main+0x14> [ 80] 0x0000000000400360 <main>..0x0000000000400375 So range list 0 for the inlined_subroutine DIE a8 is the same as range list 40 for the lexical_block DIE c2. I had hoped I could detect and then reduce the duplication of the range lists in this case with the attached patch where I just check that the basic block numbers for the ranges are the same as the ranges of its context DIE. But that doesn't actually work since by looking at the generated assembly the basic block asm labels are in the same place, the block numbers are actually different (and so there are actually two differently named/numbered labels generated at the same place). e.g: .LVL0: .LBB4: .LBB5: .loc 1 5 0 leal 42(%rdi), %eax .LBE5: .LBE4: .loc 1 12 0 leal (%rdi,%rdi), %edx .LBB8: .LBB6: .loc 1 6 0 cmpl $14, %eax .LBE6: .LBE8: .loc 1 12 0 movl %edx, k(%rip) .LVL1: .LBB9: .LBB7: .loc 1 6 0 cmovle %edi, %eax .LVL2: addl %edx, %eax .LBE7: .LBE9: .loc 1 15 0 ret .cfi_endproc [...] .section .debug_ranges,"",@progbits .Ldebug_ranges0: .quad .LBB4 .quad .LBE4 .quad .LBB8 .quad .LBE8 .quad .LBB9 .quad .LBE9 .quad 0 .quad 0 .quad .LBB5 .quad .LBE5 .quad .LBB6 .quad .LBE6 .quad .LBB7 .quad .LBE7 .quad 0 .quad 0 .quad .LFB1 .quad .LFE1 .quad 0 .quad 0 Is there a way to detect that basic blocks have the same range even though they have different block numbers? Or am I not looking/thinking about this issue correctly? Thanks, Mark
Attachment:
dup_ranges.patch
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |