[PATCH] Relax invalidation of TOP N counters in PGO.

Martin Liška mliska@suse.cz
Wed Jan 15 15:50:00 GMT 2020


Hi.

So I'm sending first version of the relaxation patch and a demonstration
source file that can demonstrate how me merge profile for indirect
functions provided on input. There are some demonstrations:

1) rm indir-call.gcda -f ; ./a.out ABCD && gcov-dump -l indir-call.gcda | grep -A2 'indirect_call 9'
indir-call.gcda:    01a90000:  18:COUNTERS indirect_call 9 counts
indir-call.gcda:                   0: 4 51084318 4 1042717606 4 1451412899 4 1149064406
indir-call.gcda:                   8: 4

All 4 values will fit in the counter (note that profile read code will divide all values by 4).

2) rm indir-call.gcda -f ; ./a.out AAABB && ./a.out B && ./a.out C && gcov-dump -l indir-call.gcda | grep -A2 'indirect_call 9'
indir-call.gcda:    01a90000:  18:COUNTERS indirect_call 9 counts
indir-call.gcda:                   0: 7 51084318 12 1042717606 12 0 0 0
indir-call.gcda:                   8: 0

Here A, B, C have frequency < 5/4.

3) rm indir-call.gcda -f ; ./a.out AABCDE && gcov-dump -l indir-call.gcda | grep -A2 'indirect_call 9'
indir-call.gcda:    01a90000:  18:COUNTERS indirect_call 9 counts
indir-call.gcda:                   0: 6 51084318 7 0 0 0 0 0
indir-call.gcda:                   8: 0

Here only A survives (2 * 4 - 1).

4) rm indir-call.gcda -f ; ./a.out AAABB && ./a.out B && gcov-dump -l indir-call.gcda | grep -A2 'indirect_call 9'
indir-call.gcda:    01a90000:  18:COUNTERS indirect_call 9 counts
indir-call.gcda:                   0: 6 51084318 12 1042717606 12 0 0 0
indir-call.gcda:                   8: 0

Merging works in between runs properly

5) rm indir-call.gcda -f ; ./a.out AAABB && ./a.out B && ./a.out C && gcov-dump -l indir-call.gcda | grep -A2 'indirect_call 9'
indir-call.gcda:    01a90000:  18:COUNTERS indirect_call 9 counts
indir-call.gcda:                   0: 7 51084318 12 1042717606 12 0 0 0
indir-call.gcda:                   8: 0

Same here, where C is discarded due to small count.

Can you please Honza take a look and provide a feedback? About the new option:
I would like not to invent a bigger complexity. Even now, the merging is quite
complex.

Martin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Smart-relaxation-of-TOP-N-counter.patch
Type: text/x-patch
Size: 8230 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20200115/4b4e3769/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: indir-call.c
Type: text/x-csrc
Size: 1014 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20200115/4b4e3769/attachment-0001.bin>


More information about the Gcc-patches mailing list