public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/2] libcpp: Avoid unnecessary ad-hoc uses for large source files
@ 2015-12-18 20:01 David Malcolm
  2015-12-18 20:01 ` [PATCH 2/2] PR c++/68819: libcpp fallbacks and -Wmisleading-indentation David Malcolm
  2015-12-21 20:10 ` [PATCH 1/2] libcpp: Avoid unnecessary ad-hoc uses for large source files Jeff Law
  0 siblings, 2 replies; 10+ messages in thread
From: David Malcolm @ 2015-12-18 20:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

When debugging PR c++/68819 I noticed an inefficiency during
the handling of locations > LINE_MAP_MAX_LOCATION_WITH_COLS.
When combining ranges for locations with
  start == caret == finish (with a NULL data ptr)
get_combined_adhoc_loc was always building an ad-hoc entry
rather than simply returning the location.

Normally can_be_stored_compactly_p returns true for such triples,
but it returns false for locations above
LINE_MAP_MAX_LOCATION_WITH_COLS (as the range-packing code isn't
designed to handle the latter).  There's a followup test within
get_combined_adhoc_loc for detecting the start == caret == finish
case, but I'd conditionalized it on the location being one of the
two reserved locations:
   locus < RESERVED_LOCATION_COUNT

That condition has been there since I introduced range-packing
(as part ofr230331).  I believe at the time I didn't realize there
was any other way for such a location triple to fail
can_be_stored_compactly_p.

These location triples occur a lot where we're in this mode:
every token, and every expression that fits on one line,
so this is wasteful.

Removing the locus < RESERVED_LOCATION_COUNT part of the
condition allows us to avoid using the ad-hoc table for these
cases.

Successfully bootstrapped&regrtested on x86_64-pc-linux-gnu
in combination with the following patch.

libcpp/ChangeLog:
	* line-map.c (get_combined_adhoc_loc): Remove condition
	on locus < RESERVED_LOCATION_COUNT when considering
	whether a caret == start == finish location can be
	simply stored as the caret location.
---
 libcpp/line-map.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index 209d0fb..c20a32b 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -196,10 +196,9 @@ get_combined_adhoc_loc (struct line_maps *set,
 	}
     }
 
-  /* We can also compactly store the reserved locations
+  /* We can also compactly store locations
      when locus == start == finish (and data is NULL).  */
-  if (locus < RESERVED_LOCATION_COUNT
-      && locus == src_range.m_start
+  if (locus == src_range.m_start
       && locus == src_range.m_finish
       && !data)
     return locus;
-- 
1.8.5.3

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-01-14 18:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-18 20:01 [PATCH 1/2] libcpp: Avoid unnecessary ad-hoc uses for large source files David Malcolm
2015-12-18 20:01 ` [PATCH 2/2] PR c++/68819: libcpp fallbacks and -Wmisleading-indentation David Malcolm
2015-12-21 21:10   ` Jeff Law
2015-12-21 21:20     ` Jakub Jelinek
2016-01-06 20:02       ` David Malcolm
2016-01-07  8:41         ` Jakub Jelinek
2016-01-06 19:54     ` David Malcolm
2016-01-08 21:20     ` [PATCH] PR preprocessor/69177 and PR c++/68819: libcpp fallbacks and -Wmisleading-indentation (v2) David Malcolm
2016-01-14 18:50       ` Jeff Law
2015-12-21 20:10 ` [PATCH 1/2] libcpp: Avoid unnecessary ad-hoc uses for large source files Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).