This is the mail archive of the gcc-patches@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]

[PATCH] Slightly decrease .debug_loc size


Hi!

I've discovered last night that (discussions about the .debug_loc pruning
aside) we sometimes generate stuff like:
        .quad   .LVL237-.Ltext0 # Location list begin address (*.LLST46)
        .quad   .LVL238-.Ltext0 # Location list end address (*.LLST46)
        .value  0x1     # Location expression size
        .byte   0x5c    # DW_OP_reg12
        .quad   .LVL238-.Ltext0 # Location list begin address (*.LLST46)
        .quad   .LVL239-.Ltext0 # Location list end address (*.LLST46)
        .value  0x1     # Location expression size
        .byte   0x5c    # DW_OP_reg12
        .quad   .LVL239-.Ltext0 # Location list begin address (*.LLST46)
        .quad   .LFE623-.Ltext0 # Location list end address (*.LLST46)
        .value  0x1     # Location expression size
        .byte   0x5c    # DW_OP_reg12
instead of more compact:
        .quad   .LVL237-.Ltext0 # Location list begin address (*.LLST46)
        .quad   .LFE623-.Ltext0 # Location list end address (*.LLST46)
        .value  0x1     # Location expression size
        .byte   0x5c    # DW_OP_reg12

The problem is if we have a var location note with reg12, then for whatever
reason a var location note for the same decl and null location followed
by a var location note for the same decl with reg12 again (and no real insns
in between the two, just some other notes).

The attached patch optimizes this case (removes var_loc_notes that don't
reference any insns (i.e. their label is the same as the next chain entry's
label)).  Bootstrapped/regtested on x86_64-linux and i686-linux.
It slightly decreases .debug_loc size (the saving is 178KB or 1.1% of .debug_loc
size for i686 cc1plus with rtl checking and 330KB or 1.0% of .debug_loc size
for x86_64 cc1plus with rtl checking).

readelf -WS obj76{3,5}/gcc/cc1plus | grep 'debug_\(loc\|info\)'
  [28] .debug_info       PROGBITS        00000000 ffc272 139e25f 00      0   0  1
  [33] .debug_loc        PROGBITS        00000000 290e3bd f95949 00      0   0  1
  [28] .debug_info       PROGBITS        00000000 ffc3f2 139e0ff 00      0   0  1
  [33] .debug_loc        PROGBITS        00000000 290e449 f6931d 00      0   0  1
readelf -WS obj76{2,4}/gcc/cc1plus | grep 'debug_\(loc\|info\)'
  [28] .debug_info       PROGBITS        0000000000000000 10dd8e8 14ad928 00      0   0  1
  [32] .debug_loc        PROGBITS        0000000000000000 2a74c04 1e2f420 00      0   0  1
  [28] .debug_info       PROGBITS        0000000000000000 10dd8e8 14ad765 00      0   0  1
  [32] .debug_loc        PROGBITS        0000000000000000 2a74b6d 1ddcb98 00      0   0  1

Ok for trunk?

	Jakub

Attachment: Y641
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]