This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [line-map] simple oneliner that speeds up track-macro-expansion
- From: Dimitrios Apostolou <jimis at gmx dot net>
- To: Dodji Seketeli <dodji at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, amonakov at gcc dot gnu dot org, abel at gcc dot gnu dot org, bonzini at gnu dot org
- Date: Tue, 5 Jun 2012 03:49:29 +0300 (EEST)
- Subject: Re: [line-map] simple oneliner that speeds up track-macro-expansion
- References: <alpine.LNX.2.02.1206040751010.4288@localhost.localdomain> <m3obozysaf.fsf@redhat.com>
Hi Dodji,
On Mon, 4 Jun 2012, Dodji Seketeli wrote:
Hello Dimitrios,
I cannot approve or deny your patch, but I have one question.
Who should I CC then? I saw that you have commits in that file.
I am wondering why this change implies better performance.
Is this because when we later want to encode a new line/column, and
hit the spot below, (in linemap_line_start via
linemap_position_for_column), we call less linemap_add (and thus
allocate less maps):
Almost. To be exact we don't even enter linemap_line_start() because of
the check in linemap_position_for_column(). As a result we avoid
almost 450K calls to linemap_line_start() (and many calls to malloc()
subsequently), for my example case of compiling reload.c. Here is the
source annotated by callgrind:
Before:
. source_location
. linemap_position_for_column (struct line_maps *set, unsigned int to_column)
5,193,344 {
649,168 source_location r = set->highest_line;
.
3,895,008 linemap_assert
. (!linemap_macro_expansion_map_p (LINEMAPS_LAST_ORDINARY_MAP (set)));
.
1,298,336 if (to_column >= set->max_column_hint)
. {
1,696,684 if (r >= 0xC000000 || to_column > 100000)
. {
. /* Running low on source_locations - disable column numbers. */
. return r;
. }
. else
. {
. struct line_map *map = LINEMAPS_LAST_ORDINARY_MAP (set);
5,938,394 r = linemap_line_start (set, SOURCE_LINE (map, r), to_column + 50);
36,425,117 => line-map.c:linemap_line_start (424171x)
. }
. }
649,168 r = r + to_column;
1,298,336 if (r >= set->highest_location)
640,785 set->highest_location = r;
. return r;
3,895,008 }
After
. source_location
. linemap_position_for_column (struct line_maps *set, unsigned int to_column)
5,193,344 {
649,168 source_location r = set->highest_line;
.
3,895,008 linemap_assert
. (!linemap_macro_expansion_map_p (LINEMAPS_LAST_ORDINARY_MAP (set)));
.
1,298,336 if (to_column >= set->max_column_hint)
. {
48 if (r >= 0xC000000 || to_column > 100000)
. {
. /* Running low on source_locations - disable column numbers. */
. return r;
. }
. else
. {
. struct line_map *map = LINEMAPS_LAST_ORDINARY_MAP (set);
168 r = linemap_line_start (set, SOURCE_LINE (map, r), to_column + 50);
2,573 => line-map.c:linemap_line_start (12x)
. }
. }
649,168 r = r + to_column;
1,298,336 if (r >= set->highest_location)
640,805 set->highest_location = r;
. return r;
3,895,008 }
Dimitris