public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: David Malcolm <dmalcolm@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 2/2] PR c++/68819: libcpp fallbacks and -Wmisleading-indentation
Date: Mon, 21 Dec 2015 21:10:00 -0000	[thread overview]
Message-ID: <56786AB9.4080602@redhat.com> (raw)
In-Reply-To: <1450470070-31069-2-git-send-email-dmalcolm@redhat.com>

On 12/18/2015 01:21 PM, David Malcolm wrote:

> I don't think there's a way to fix -Wmisleading-indentation if we're
> in this state, so the first part of the following patch detects if
> this has happened, and effectively turns off -Wmisleading-indentation
> from that point onwards.  To avoid a false sense of security, the
> patch issues a "sorry" at the that point, currently with this wording:
> location-overflow-test-1.c:17:0: sorry, unimplemented: -Wmisleading-indentation is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers
Seems reasonable.  I can't see any way to get indentation warnings if we 
don't have column info.

>
> Should this greater chance of hitting LINE_MAP_MAX_LOCATION_WITH_COLS
> be filed as a separate PR?
I was originally going to say no, but I suspect there'll be a few folks 
that are going to bump up against it.  Might as well have a canonical BZ 
for it.


>
> The second part of the patch resolves this by adding an additional
> level of fallback: a new LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES
> threshold (currently 0x50000000) that occurs well before
> the LINE_MAP_MAX_LOCATION_WITH_COLS threshold (0x60000000).
> Once we reach the new LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES
> threshold, the range-packing optimization is disabled (with a transition
> to an ordinary map with m_range_bits == 0), effectively giving us a
> much "longer runway" before the LINE_MAP_MAX_LOCATION_WITH_COLS
> threshold is hit, at the cost to requiring the use of the ad-hoc
> table for every location (e.g. every token of length > 1).
> I haven't yet done performance testing on this.
>
> The patch adds test coverage for this by using a plugin to simulate
> the two levels of degraded locations.
>
> Rough calculations, assuming 7 bits of columns,
> LINE_MAP_MAX_LOCATION_WITH_COLS == 0x60000000
> LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES == 0x50000000
>
> gcc 5:
>    0x60000000 / 128 per line = 12,582,912 lines of code before
>    hitting the has-column-information limit.
>
> gcc 6 trunk:
>    0x60000000 / (128 * 32) per line = 393,216 lines of code before
>    hitting the has-column-information limit.
>
> with this patch:
>    0x50000000 / (128 * 32) per line = 327,680 lines of code before
>    hitting the range-packing limit, then:
>    0x10000000 / 128 = 2,097,152 lines of code before hitting the
>    has-column-information limit.
>    giving 2,424,832 lines of code total before hitting the
>    has-column-information limit.
>
> These numbers will be less in the face of lines longer than
> 127 characters.
>
> If the increased use of the ad-hoc table is an issue, another
> approach might be to simply disable range-handling for locations
> that go beyond a threshold location_t value: attempts to combine
> locations above that value lead to you simply getting the caret
> location.  If we take this approach, I think we'd still want to
> have a range threshold before the column one, so that we preserve
> the ability to have column information for these pure-caret
> locations.
>
> Alternatively, the range bits could be lowered from 5 to 4,
> doubling the lines we can handle before hitting the limit:
> 0x60000000 / (128 * 16) = 786,432, though that doesn't buy
> us much compared to the approach in this patch.
>
> Successfully bootstrapped&regrtested on x86_64-pc-linux-gnu.
>
> Thoughts?
>
> gcc/c-family/ChangeLog:
> 	PR c++/68819
> 	* c-indentation.c (get_visual_column): Handle the column
> 	number being zero by effectively disabling the warning, with
> 	a "sorry".
This part is fine as-is.


>
> gcc/testsuite/ChangeLog:
> 	PR c++/68819
> 	* gcc.dg/plugin/location-overflow-test-1.c: New test case.
> 	* gcc.dg/plugin/location-overflow-test-2.c: New test case.
> 	* gcc.dg/plugin/location_overflow_plugin.c: New test plugin.
> 	* gcc.dg/plugin/plugin.exp (plugin_test_list): Add the above.
>
> libcpp/ChangeLog:
> 	PR c++/68819
> 	* line-map.c (LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES): New
> 	constant.
> 	(LINE_MAP_MAX_LOCATION_WITH_COLS): Add note about unit tests
> 	to comment.
> 	(can_be_stored_compactly_p): Reduce threshold from
> 	LINE_MAP_MAX_LOCATION_WITH_COLS to
> 	LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES.
> 	(get_combined_adhoc_loc): Likewise.
> 	(get_range_from_loc): Likewise.
> 	(linemap_line_start): Ensure that a new ordinary map is created
> 	when transitioning from range-packing being enabled to disabled,
> 	at the LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES threshold.  Set
> 	range_bits to 0 for new ordinary maps when beyond this limit.
> 	Prevent the "increase the column bits of a freshly created map"
> 	optimization if the range bits has reduced.

> +
> +/* We use location_overflow_plugin.c to inject the
> +   which injects the case that location_t values have exceeded
> +   LINE_MAP_MAX_LOCATION_WITH_COLS, and hence no column
> +   numbers are available.  */
It's just a test, but the comment doesn't parse.  "to inject the which" 
:-)  It's repeated in the second test as well.

With the comment fixes this is OK.

jeff

  reply	other threads:[~2015-12-21 21:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56786AB9.4080602@redhat.com \
    --to=law@redhat.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).