From: Qing Zhao <QING.ZHAO@ORACLE.COM>
To: David Malcolm <dmalcolm@redhat.com>,
Richard Sandiford <richard.sandiford@arm.com>,
Jakub@redhat.com, richard Biener <richard.guenther@gmail.com>
Cc: Qing Zhao via Gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [Version 4][PATCH][gcc][PR94230]provide an option to change the size limitation for -Wmisleading-indent
Date: Fri, 24 Apr 2020 17:22:24 -0500 [thread overview]
Message-ID: <B18B6BD0-0F6C-4AEE-9A79-8C0909887157@ORACLE.COM> (raw)
In-Reply-To: <a407e6691ad5d7235c79d9c5eb251ddd401036f9.camel@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1013 bytes --]
Hi, Dave,
Thanks a lot for the review and comments.
I just updated the patch with all your suggestions, bootstrapped it and run regression test, no any issue.
The newest patch is attached with this email.
Richard/Jakub, please advise on whether I can commit this patch to Gcc10?
Thanks a lot.
Qing
gcc/c-family/ChangeLog:
2020-04-24 qing zhao <qing.zhao@oracle.com>
* c-indentation.c (get_visual_column): Add a hint to use the new
-flarge-source-files option.
gcc/ChangeLog:
2020-04-24 qing zhao <qing.zhao@oracle.com>
* common.opt: Add -flarge-source-files.
* doc/invoke.texi: Document it.
* toplev.c (process_options): Set line_table->default_range_bits
to 0 when flag_large_source_files is true.
gcc/testsuite/ChangeLog:
2020-04-24 qing zhao <qing.zhao@oracle.com>
* gcc.dg/plugin/location-overflow-test-1.c (fn_1): New message to
verify that hint about -flarge-source-files is emitted.
[-- Attachment #2: PR94230.patch --]
[-- Type: application/octet-stream, Size: 4820 bytes --]
From 512a8ccce1e6ed8889cd7144459c130935abf0de Mon Sep 17 00:00:00 2001
From: qing zhao <qing.zhao@oracle.com>
Date: Fri, 24 Apr 2020 16:50:18 +0200
Subject: [PATCH] Fix PR94230
---
gcc/c-family/c-indentation.c | 5 +++++
gcc/common.opt | 5 +++++
gcc/doc/invoke.texi | 19 +++++++++++++++++--
.../gcc.dg/plugin/location-overflow-test-1.c | 2 +-
gcc/toplev.c | 3 +++
5 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/gcc/c-family/c-indentation.c b/gcc/c-family/c-indentation.c
index f737555db0e..baa506347cd 100644
--- a/gcc/c-family/c-indentation.c
+++ b/gcc/c-family/c-indentation.c
@@ -67,6 +67,11 @@ get_visual_column (expanded_location exploc, location_t loc,
"%<-Wmisleading-indentation%> is disabled from this point"
" onwards, since column-tracking was disabled due to"
" the size of the code/headers");
+ if (!flag_large_source_files)
+ inform (loc,
+ "adding %<-flarge-source-files%> will allow for more"
+ " column-tracking support, at the expense of compilation"
+ " and memory");
}
return false;
}
diff --git a/gcc/common.opt b/gcc/common.opt
index d33383b523c..30d05734d16 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1609,6 +1609,11 @@ fkeep-gc-roots-live
Common Undocumented Report Var(flag_keep_gc_roots_live) Optimization
; Always keep a pointer to a live memory block
+flarge-source-files
+Common Report Var(flag_large_source_files) Init(0)
+Improve GCC's ability to track column numbers in large source files,
+at the expense of slower compilation.
+
floop-parallelize-all
Common Report Var(flag_loop_parallelize_all) Optimization
Mark all loops as parallel.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index a37a2ee9c19..bdde7c1d881 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -574,8 +574,8 @@ Objective-C and Objective-C++ Dialects}.
-dD -dI -dM -dN -dU @gol
-fdebug-cpp -fdirectives-only -fdollars-in-identifiers @gol
-fexec-charset=@var{charset} -fextended-identifiers @gol
--finput-charset=@var{charset} -fmacro-prefix-map=@var{old}=@var{new} @gol
--fmax-include-depth=@var{depth} @gol
+-finput-charset=@var{charset} -flarge-source-files @gol
+-fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth} @gol
-fno-canonical-system-headers -fpch-deps -fpch-preprocess @gol
-fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion @gol
-fwide-exec-charset=@var{charset} -fworking-directory @gol
@@ -14183,6 +14183,21 @@ This option may be useful in conjunction with the @option{-B} or
perform additional processing of the program source between
normal preprocessing and compilation.
+@item -flarge-source-files
+@opindex flarge-source-files
+Adjust GCC to expect large source files, at the expense of slower
+compilation and higher memory usage.
+
+Specifically, GCC normally tracks both column numbers and line numbers
+within source files and it normally prints both of these numbers in
+diagnostics. However, once it has processed a certain number of source
+lines, it stops tracking column numbers and only tracks line numbers.
+This means that diagnostics for later lines do not include column numbers.
+It also means that options like @option{-Wmisleading-indentation} cease to work
+at that point, although the compiler prints a note if this happens.
+Passing @option{-flarge-source-files} significantly increases the number
+of source lines that GCC can process before it stops tracking columns.
+
@end table
@node Assembler Options
diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-1.c b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-1.c
index 1a80a668a0f..a3ac12d3b46 100644
--- a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-1.c
+++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-1.c
@@ -13,7 +13,7 @@ int
fn_1 (int flag)
{
int x = 4, y = 5;
- if (flag) x = 3; y = 2; /* { dg-message "-:disabled from this point" } */
+ if (flag) x = 3; y = 2; /* { dg-message "-:disabled from this point" "adding '-flarge-source-files'" } */
return x * y;
}
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 4c8be502c71..b3230b71b9d 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1854,6 +1854,9 @@ process_options (void)
hash_table_sanitize_eq_limit
= param_hash_table_verification_limit;
+ if (flag_large_source_files)
+ line_table->default_range_bits = 0;
+
/* Please don't change global_options after this point, those changes won't
be reflected in optimization_{default,current}_node. */
}
--
2.11.0
[-- Attachment #3: Type: text/plain, Size: 2138 bytes --]
> On Apr 23, 2020, at 5:13 PM, David Malcolm <dmalcolm@redhat.com> wrote:
>
> On Thu, 2020-04-23 at 16:05 -0500, Qing Zhao wrote:
>
>> Hi, Richard,
>>
>> This is the 3rd version of the patch, updated based on your previous comments.
>
> Thanks for working on this, and to Richard for the useful comments.
>
>> Please take a look at it and let me know whether it’s okay to commit?
>
> I like the overall approach.
>
> Some nits inline.
>
>
> Maybe: "Verify that hint about -flarge-source-files is emitted".
>
>
>> + if (!flag_large_source_files)
>> + inform (loc,
>> + "please add %<-flarge-source-files%> to invoke more"
>> + " column-tracking for large source files");
>
> It's great having a hint here, but I don't love the wording of the
> hint.
>
> Maybe reword to:
>
> "adding %<-flarge-source-files%> will allow for more column-tracking
> support, at the expense of compilation time and memory".
>
> or somesuch.
>
>> +This means that diagnostics for later lines do not include column numbers.
>> +It also means that options like @option{-Wmisleading-indent} cease to work
> ^^^^^^^^^^^^^^^^^^^
> This should be: -Wmisleading-indentation
>
>> +at that point, although the compiler prints a note if this happens.
>> +Passing @option{-flarge-source-files} significantly increases the number
>> +of source lines that GCC can process before it stops tracking column.
> ^^^^^^
> This should be: columns
>
>> + if (flag) x = 3; y = 2; /* { dg-message "-:disabled from this point" "add '-flarge-source-files'" } */
>
> May need updating to match the hint message.
>
> [...]
>
> This is OK for stage 1 with those nits fixed.
>
> There was talk earlier in the thread about fixing this in GCC 10.
>
> Richi/Jakub: is this OK for stage 4? Although it adds a new command-
> line option, it's a workaround for a regression introduced in GCC 6 and
> should be low risk.
>
> Thanks
> Dave
>
next prev parent reply other threads:[~2020-04-24 22:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-03 19:55 [PATCH][gcc][PR94230]provide " Qing Zhao
2020-04-08 19:39 ` PING " Qing Zhao
2020-04-15 20:30 ` Fwd: " Qing Zhao
2020-04-21 14:04 ` Richard Sandiford
2020-04-21 15:21 ` David Malcolm
2020-04-21 18:46 ` Richard Sandiford
2020-04-22 14:22 ` Qing Zhao
2020-04-23 14:41 ` [Version 2][PATCH][gcc][PR94230]provide " Qing Zhao
2020-04-23 18:27 ` Richard Sandiford
2020-04-23 19:52 ` Qing Zhao
2020-04-23 21:05 ` [Version 3][PATCH][gcc][PR94230]provide " Qing Zhao
2020-04-23 22:13 ` David Malcolm
2020-04-24 22:22 ` Qing Zhao [this message]
2020-04-24 22:36 ` [Version 4][PATCH][gcc][PR94230]provide " David Malcolm
2020-04-27 14:23 ` Qing Zhao
2020-05-06 18:40 ` Committed [Version 3][PATCH][gcc][PR94230]provide " Qing Zhao
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=B18B6BD0-0F6C-4AEE-9A79-8C0909887157@ORACLE.COM \
--to=qing.zhao@oracle.com \
--cc=Jakub@redhat.com \
--cc=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
--cc=richard.sandiford@arm.com \
/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).