This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Backports to gcc 7.x
- From: Martin Liška <mliska at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 22 Jun 2017 13:32:54 +0200
- Subject: Backports to gcc 7.x
- Authentication-results: sourceware.org; auth=none
And there are backports for GCC 7 branch that I'm going to install.
Martin
>From 818c118793ae5e95948dd95471561c261247924c Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 19 Jun 2017 13:27:48 +0000
Subject: [PATCH 12/12] Backport r249368
gcc/ChangeLog:
2017-06-19 Martin Liska <mliska@suse.cz>
PR sanitizer/80879
* gimplify.c (gimplify_switch_expr):
Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST.
gcc/testsuite/ChangeLog:
2017-06-19 Martin Liska <mliska@suse.cz>
PR sanitizer/80879
* gcc.dg/asan/use-after-scope-switch-4.c: New test.
---
gcc/gimplify.c | 3 +-
.../gcc.dg/asan/use-after-scope-switch-4.c | 35 ++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/asan/use-after-scope-switch-4.c
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index b93993c7856..201ffc1dbac 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -2276,7 +2276,8 @@ gimplify_switch_expr (tree *expr_p, gimple_seq *pre_p)
/* Do not create live_switch_vars if SWITCH_BODY is not a BIND_EXPR. */
saved_live_switch_vars = gimplify_ctxp->live_switch_vars;
- if (TREE_CODE (SWITCH_BODY (switch_expr)) == BIND_EXPR)
+ tree_code body_type = TREE_CODE (SWITCH_BODY (switch_expr));
+ if (body_type == BIND_EXPR || body_type == STATEMENT_LIST)
gimplify_ctxp->live_switch_vars = new hash_set<tree> (4);
else
gimplify_ctxp->live_switch_vars = NULL;
diff --git a/gcc/testsuite/gcc.dg/asan/use-after-scope-switch-4.c b/gcc/testsuite/gcc.dg/asan/use-after-scope-switch-4.c
new file mode 100644
index 00000000000..babffcc1cbe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/use-after-scope-switch-4.c
@@ -0,0 +1,35 @@
+// { dg-do run }
+// { dg-additional-options "-fdump-tree-gimple" }
+
+int *ptr;
+
+struct a
+{
+ int c;
+};
+
+int main(int argc, char **argv)
+{
+ struct a e;
+ e.c = 2;
+ int x = 0;
+
+ for (;;)
+ switch (e.c)
+ case 3:
+ {
+ int resxxx;
+ case 2:
+ ptr = &resxxx;
+ *ptr = 123;
+
+ if (x)
+ return 0;
+ else
+ x = 1;
+ }
+
+ return 1;
+}
+
+/* { dg-final { scan-tree-dump-times "ASAN_MARK \\(UNPOISON, &resxxx, \[0-9\]\\);" 2 "gimple" } } */
--
2.13.1
>From d7a527e045b18511736a7eccb153ee54efa6d130 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 31 May 2017 11:40:13 +0000
Subject: [PATCH 11/12] Backport r248729
gcc/ChangeLog:
2017-05-31 Martin Liska <mliska@suse.cz>
PR target/79155
* config/i386/cpuid.h: Fix typo in a comment in cpuid.h.
---
gcc/config/i386/cpuid.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/config/i386/cpuid.h b/gcc/config/i386/cpuid.h
index f915d2dbd5a..b3b0f912c98 100644
--- a/gcc/config/i386/cpuid.h
+++ b/gcc/config/i386/cpuid.h
@@ -179,7 +179,7 @@
/* Return highest supported input value for cpuid instruction. ext can
- be either 0x0 or 0x8000000 to return highest supported value for
+ be either 0x0 or 0x80000000 to return highest supported value for
basic or extended cpuid information. Function returns 0 if cpuid
is not supported or whatever cpuid returns in eax register. If sig
pointer is non-null, then first four bytes of the signature
--
2.13.1
>From 07ae8f53f6ce2248f70799ac3ef3a41ae402341b Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 30 May 2017 08:02:03 +0000
Subject: [PATCH 10/12] Backport r248647
gcc/ChangeLog:
2017-05-30 Martin Liska <mliska@suse.cz>
PR other/80909
* auto-profile.c (get_function_decl_from_block): Fix
parenthesis.
---
gcc/auto-profile.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index 4e498dc6b0e..e353e04df76 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -355,7 +355,7 @@ get_function_decl_from_block (tree block)
{
tree decl;
- if (LOCATION_LOCUS (BLOCK_SOURCE_LOCATION (block) == UNKNOWN_LOCATION))
+ if (LOCATION_LOCUS (BLOCK_SOURCE_LOCATION (block)) == UNKNOWN_LOCATION)
return NULL_TREE;
for (decl = BLOCK_ABSTRACT_ORIGIN (block);
--
2.13.1
>From 1daeb2571e2406600d52428b7186c51c36ac3844 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 26 May 2017 11:05:52 +0000
Subject: [PATCH 09/12] Backport r248489
gcc/ChangeLog:
2017-05-26 Martin Liska <mliska@suse.cz>
PR ipa/80663
* params.def: Bound partial-inlining-entry-probability param.
gcc/testsuite/ChangeLog:
2017-05-26 Martin Liska <mliska@suse.cz>
PR ipa/80663
* g++.dg/ipa/pr80212.C: Remove the test as it does not longer
split at the problematic spot.
* gcc.dg/ipa/pr48195.c: Change 101 to 100 as 101 is no longer
a valid value of the param.
---
gcc/params.def | 2 +-
gcc/testsuite/g++.dg/ipa/pr80212.C | 18 ------------------
gcc/testsuite/gcc.dg/ipa/pr48195.c | 2 +-
3 files changed, 2 insertions(+), 20 deletions(-)
delete mode 100644 gcc/testsuite/g++.dg/ipa/pr80212.C
diff --git a/gcc/params.def b/gcc/params.def
index 1b058e49860..6b07518a34b 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -126,7 +126,7 @@ DEFPARAM (PARAM_COMDAT_SHARING_PROBABILITY,
DEFPARAM (PARAM_PARTIAL_INLINING_ENTRY_PROBABILITY,
"partial-inlining-entry-probability",
"Maximum probability of the entry BB of split region (in percent relative to entry BB of the function) to make partial inlining happen.",
- 70, 0, 0)
+ 70, 0, 100)
/* Limit the number of expansions created by the variable expansion
optimization to avoid register pressure. */
diff --git a/gcc/testsuite/g++.dg/ipa/pr80212.C b/gcc/testsuite/g++.dg/ipa/pr80212.C
deleted file mode 100644
index 60d3b613035..00000000000
--- a/gcc/testsuite/g++.dg/ipa/pr80212.C
+++ /dev/null
@@ -1,18 +0,0 @@
-// PR ipa/80212
-// { dg-options "-O2 --param partial-inlining-entry-probability=403796683 -fno-early-inlining" }
-
-struct b
-{
- virtual b *c () const;
-};
-struct d : virtual b
-{
-};
-struct e : d
-{
- e *
- c () const
- {
- }
-};
-main () { e a; }
diff --git a/gcc/testsuite/gcc.dg/ipa/pr48195.c b/gcc/testsuite/gcc.dg/ipa/pr48195.c
index 2e38452d598..25e80bab8f8 100644
--- a/gcc/testsuite/gcc.dg/ipa/pr48195.c
+++ b/gcc/testsuite/gcc.dg/ipa/pr48195.c
@@ -1,5 +1,5 @@
/* { dg-do link } */
-/* { dg-options "-O2 -flto --param partial-inlining-entry-probability=101" } */
+/* { dg-options "-O2 -flto --param partial-inlining-entry-probability=100" } */
/* { dg-require-effective-target lto } */
extern void abort(void);
--
2.13.1
>From 874962f5f05da9ca4676af91fd6dc4429b3373f9 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 16 May 2017 08:57:05 +0000
Subject: [PATCH 08/12] Backport r248089
gcc/ChangeLog:
2017-05-16 Martin Liska <mliska@suse.cz>
PR ipa/79849.
PR ipa/79850.
* ipa-devirt.c (warn_types_mismatch): Fix typo.
(odr_types_equivalent_p): Likewise.
---
gcc/ipa-devirt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index e013a26a4a0..0d214170c24 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -1226,7 +1226,7 @@ warn_types_mismatch (tree t1, tree t2, location_t loc1, location_t loc2)
if (types_odr_comparable (t1, t2, true)
&& types_same_for_odr (t1, t2, true))
inform (loc_t1,
- "type %qT itself violate the C++ One Definition Rule", t1);
+ "type %qT itself violates the C++ One Definition Rule", t1);
/* Prevent pointless warnings like "struct aa" should match "struct aa". */
else if (TYPE_NAME (t1) == TYPE_NAME (t2)
&& TREE_CODE (t1) == TREE_CODE (t2) && !loc_t2_useful)
@@ -1573,7 +1573,7 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned,
if (DECL_ARTIFICIAL (f1))
break;
warn_odr (t1, t2, f1, f2, warn, warned,
- G_("fields has different layout "
+ G_("fields have different layout "
"in another translation unit"));
return false;
}
--
2.13.1
>From b837471389d3eab423e25852cd17a779dd78119c Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 15 May 2017 12:48:35 +0000
Subject: [PATCH 07/12] Backport r248060
gcc/ChangeLog:
2017-05-15 Martin Liska <mliska@suse.cz>
PR driver/31468
* gcc.c (process_command): Do not allow empty argument of -o option.
---
gcc/gcc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 826b012cd77..9721f94b4f6 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -4472,6 +4472,9 @@ process_command (unsigned int decoded_options_count,
output_file);
}
+ if (output_file != NULL && output_file[0] == '\0')
+ fatal_error (input_location, "output filename may not be empty");
+
/* If -save-temps=obj and -o name, create the prefix to use for %b.
Otherwise just make -save-temps=obj the same as -save-temps=cwd. */
if (save_temps_flag == SAVE_TEMPS_OBJ && save_temps_prefix != NULL)
--
2.13.1
>From 7e193c2bc857e7264e69d668785b1342e4f715e4 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 2 May 2017 15:37:41 +0000
Subject: [PATCH 06/12] Backport r247507
gcc/ChangeLog:
2017-05-02 Martin Liska <mliska@suse.cz>
* doc/gcov.texi: Add missing preposition.
* gcov.c (function_info::function_info): Properly fill up
all member variables.
---
gcc/doc/gcov.texi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/doc/gcov.texi b/gcc/doc/gcov.texi
index c96f86df830..706aa6cf0b0 100644
--- a/gcc/doc/gcov.texi
+++ b/gcc/doc/gcov.texi
@@ -325,7 +325,7 @@ containing no code. Unexecuted lines are marked @samp{#####} or
@samp{====}, depending on whether they are reachable by
non-exceptional paths or only exceptional paths such as C++ exception
handlers, respectively. Given @samp{-a} option, unexecuted blocks are
-marked @samp{$$$$$} or @samp{%%%%%}, depending whether a basic block
+marked @samp{$$$$$} or @samp{%%%%%}, depending on whether a basic block
is reachable via non-exceptional or exceptional paths.
Some lines of information at the start have @var{line_number} of zero.
--
2.13.1
>From e9949eb660cddf527fc84900e1796b9f768196f1 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 2 May 2017 09:38:55 +0000
Subject: [PATCH 05/12] Backport r247485
gcc/ChangeLog:
2017-05-02 Martin Liska <mliska@suse.cz>
PR other/80589
* common.opt: Fix typo.
* doc/invoke.texi: Likewise.
---
gcc/common.opt | 2 +-
gcc/doc/invoke.texi | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/common.opt b/gcc/common.opt
index 4021622cf5c..437db8e8615 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2492,7 +2492,7 @@ flow and turn the statement with erroneous or undefined behavior into a trap.
fisolate-erroneous-paths-attribute
Common Report Var(flag_isolate_erroneous_paths_attribute) Optimization
-Detect paths that trigger erroneous or undefined behavior due a null value
+Detect paths that trigger erroneous or undefined behavior due to a null value
being used in a way forbidden by a returns_nonnull or nonnull
attribute. Isolate those paths from the main control flow and turn the
statement with erroneous or undefined behavior into a trap.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 88be6c3b640..297fa32aa2b 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -9902,7 +9902,7 @@ The maximum number of insns of an unswitched loop.
The maximum number of branches unswitched in a single loop.
@item max-loop-headers-insns
-The maximum number of insns in loop header duplicated by he copy loop headers
+The maximum number of insns in loop header duplicated by the copy loop headers
pass.
@item lim-expensive
--
2.13.1
>From 788c75af821e035c7c4c7558a4b7b97bafb88472 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 28 Apr 2017 12:51:57 +0000
Subject: [PATCH 04/12] Backport r247377
gcc/ChangeLog:
2017-04-28 Martin Liska <mliska@suse.cz>
* doc/gcov.texi: Enhance documentation of gcov.
---
gcc/doc/gcov.texi | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/gcc/doc/gcov.texi b/gcc/doc/gcov.texi
index 1befb5a3e08..c96f86df830 100644
--- a/gcc/doc/gcov.texi
+++ b/gcc/doc/gcov.texi
@@ -324,7 +324,9 @@ command line option. The @var{execution_count} is @samp{-} for lines
containing no code. Unexecuted lines are marked @samp{#####} or
@samp{====}, depending on whether they are reachable by
non-exceptional paths or only exceptional paths such as C++ exception
-handlers, respectively.
+handlers, respectively. Given @samp{-a} option, unexecuted blocks are
+marked @samp{$$$$$} or @samp{%%%%%}, depending whether a basic block
+is reachable via non-exceptional or exceptional paths.
Some lines of information at the start have @var{line_number} of zero.
These preamble lines are of the form
@@ -675,5 +677,5 @@ it. This can be overcome by, for example, setting the environment as
setting will name the data file @file{/target/run/build/foo.gcda}.
You must move the data files to the expected directory tree in order to
-use them for profile directed optimizations (@option{--use-profile}), or to
+use them for profile directed optimizations (@option{-fprofile-use}), or to
use the @command{gcov} tool.
--
2.13.1
>From f27159d88109b92e208dc4a7988d3becf33a51d1 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 28 Apr 2017 12:51:40 +0000
Subject: [PATCH 03/12] Backport r247376
gcc/ChangeLog:
2017-04-28 Martin Liska <mliska@suse.cz>
* doc/gcov.texi: Sort options in alphabetic order.
* doc/gcov-dump.texi: Likewise.
* doc/gcov-tool.texi: Likewise.
* gcov.c (print_usage): Likewise.
* gcov-dump.c (print_usage): Likewise.
* gcov-tool.c (print_merge_usage_message): Likewise.
(print_rewrite_usage_message): Likewise.
(print_overlap_usage_message): Likewise.
---
gcc/doc/gcov-dump.texi | 10 ++--
gcc/doc/gcov-tool.texi | 50 +++++++++---------
gcc/doc/gcov.texi | 137 +++++++++++++++++++++++++------------------------
gcc/gcov-dump.c | 2 +-
gcc/gcov-tool.c | 10 ++--
gcc/gcov.c | 2 +-
6 files changed, 108 insertions(+), 103 deletions(-)
diff --git a/gcc/doc/gcov-dump.texi b/gcc/doc/gcov-dump.texi
index d7931fd3a19..26653d28def 100644
--- a/gcc/doc/gcov-dump.texi
+++ b/gcc/doc/gcov-dump.texi
@@ -72,11 +72,6 @@ gcov-dump [@option{-v}|@option{--version}]
Display help about using @command{gcov-dump} (on the standard output), and
exit without doing any further processing.
-@item -v
-@itemx --version
-Display the @command{gcov-dump} version number (on the standard output),
-and exit without doing any further processing.
-
@item -l
@itemx --long
Dump content of records.
@@ -85,6 +80,11 @@ Dump content of records.
@itemx --positions
Dump positions of records.
+@item -v
+@itemx --version
+Display the @command{gcov-dump} version number (on the standard output),
+and exit without doing any further processing.
+
@item -w
@itemx --working-sets
Dump working set computed from summary.
diff --git a/gcc/doc/gcov-tool.texi b/gcc/doc/gcov-tool.texi
index 86044fc1c0b..79f6d96f5ce 100644
--- a/gcc/doc/gcov-tool.texi
+++ b/gcc/doc/gcov-tool.texi
@@ -113,23 +113,23 @@ gcov-tool @r{[}@var{global-options}@r{]} SUB_COMMAND @r{[}@var{sub_command-optio
gcov-tool [@option{-v}|@option{--version}] [@option{-h}|@option{--help}]
gcov-tool merge [merge-options] @var{directory1} @var{directory2}
+ [@option{-o}|@option{--output} @var{directory}]
[@option{-v}|@option{--verbose}]
- [@option{-o}|@option{ --output} @var{directory}]
[@option{-w}|@option{--weight} @var{w1,w2}]
gcov-tool rewrite [rewrite-options] @var{directory}
- [@option{-v}|@option{--verbose}]
+ [@option{-n}|@option{--normalize} @var{long_long_value}]
[@option{-o}|@option{--output} @var{directory}]
[@option{-s}|@option{--scale} @var{float_or_simple-frac_value}]
- [@option{-n}|@option{--normalize} @var{long_long_value}]
+ [@option{-v}|@option{--verbose}]
gcov-tool overlap [overlap-options] @var{directory1} @var{directory2}
- [@option{-v}|@option{--verbose}]
- [@option{-h}|@option{--hotonly}]
[@option{-f}|@option{--function}]
[@option{-F}|@option{--fullname}]
+ [@option{-h}|@option{--hotonly}]
[@option{-o}|@option{--object}]
[@option{-t}|@option{--hot_threshold}] @var{float}
+ [@option{-v}|@option{--verbose}]
@c man end
@c man begin SEEALSO
@@ -152,17 +152,17 @@ and exit without doing any further processing.
@item merge
Merge two profile directories.
-
@table @gcctabopt
-@item -v
-@itemx --verbose
-Set the verbose mode.
@item -o @var{directory}
@itemx --output @var{directory}
Set the output profile directory. Default output directory name is
@var{merged_profile}.
+@item -v
+@itemx --verbose
+Set the verbose mode.
+
@item -w @var{w1},@var{w2}
@itemx --weight @var{w1},@var{w2}
Set the merge weights of the @var{directory1} and @var{directory2},
@@ -171,11 +171,12 @@ respectively. The default weights are 1 for both.
@item rewrite
Read the specified profile directory and rewrite to a new directory.
-
@table @gcctabopt
-@item -v
-@itemx --verbose
-Set the verbose mode.
+
+@item -n @var{long_long_value}
+@itemx --normalize <long_long_value>
+Normalize the profile. The specified value is the max counter value
+in the new profile.
@item -o @var{directory}
@itemx --output @var{directory}
@@ -186,10 +187,9 @@ Set the output profile directory. Default output name is @var{rewrite_profile}.
Scale the profile counters. The specified value can be in floating point value,
or simple fraction value form, such 1, 2, 2/3, and 5/3.
-@item -n @var{long_long_value}
-@itemx --normalize <long_long_value>
-Normalize the profile. The specified value is the max counter value
-in the new profile.
+@item -v
+@itemx --verbose
+Set the verbose mode.
@end table
@item overlap
@@ -201,14 +201,6 @@ matched counters and p1_sum_all and p2_sum_all are the sum of counter
values in profile 1 and profile 2, respectively.
@table @gcctabopt
-@item -v
-@itemx --verbose
-Set the verbose mode.
-
-@item -h
-@itemx --hotonly
-Only print info for hot objects/functions.
-
@item -f
@itemx --function
Print function level overlap score.
@@ -217,6 +209,10 @@ Print function level overlap score.
@itemx --fullname
Print full gcda filename.
+@item -h
+@itemx --hotonly
+Only print info for hot objects/functions.
+
@item -o
@itemx --object
Print object level overlap score.
@@ -224,6 +220,10 @@ Print object level overlap score.
@item -t @var{float}
@itemx --hot_threshold <float>
Set the threshold for hot counter value.
+
+@item -v
+@itemx --verbose
+Set the verbose mode.
@end table
@end table
diff --git a/gcc/doc/gcov.texi b/gcc/doc/gcov.texi
index d728444e1e7..1befb5a3e08 100644
--- a/gcc/doc/gcov.texi
+++ b/gcc/doc/gcov.texi
@@ -143,15 +143,6 @@ gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entry for @file{gcc}.
@c man begin OPTIONS
@table @gcctabopt
-@item -h
-@itemx --help
-Display help about using @command{gcov} (on the standard output), and
-exit without doing any further processing.
-
-@item -v
-@itemx --version
-Display the @command{gcov} version number (on the standard output),
-and exit without doing any further processing.
@item -a
@itemx --all-blocks
@@ -172,68 +163,18 @@ be shown, unless the @option{-u} option is given.
Write branch frequencies as the number of branches taken, rather than
the percentage of branches taken.
-@item -n
-@itemx --no-output
-Do not create the @command{gcov} output file.
-
-@item -l
-@itemx --long-file-names
-Create long file names for included source files. For example, if the
-header file @file{x.h} contains code, and was included in the file
-@file{a.c}, then running @command{gcov} on the file @file{a.c} will
-produce an output file called @file{a.c##x.h.gcov} instead of
-@file{x.h.gcov}. This can be useful if @file{x.h} is included in
-multiple source files and you want to see the individual
-contributions. If you use the @samp{-p} option, both the including
-and included file names will be complete path names.
-
-@item -p
-@itemx --preserve-paths
-Preserve complete path information in the names of generated
-@file{.gcov} files. Without this option, just the filename component is
-used. With this option, all directories are used, with @samp{/} characters
-translated to @samp{#} characters, @file{.} directory components
-removed and unremoveable @file{..}
-components renamed to @samp{^}. This is useful if sourcefiles are in several
-different directories.
-
-@item -r
-@itemx --relative-only
-Only output information about source files with a relative pathname
-(after source prefix elision). Absolute paths are usually system
-header files and coverage of any inline functions therein is normally
-uninteresting.
+@item -d
+@itemx --display-progress
+Display the progress on the standard output.
@item -f
@itemx --function-summaries
Output summaries for each function in addition to the file level summary.
-@item -o @var{directory|file}
-@itemx --object-directory @var{directory}
-@itemx --object-file @var{file}
-Specify either the directory containing the gcov data files, or the
-object path name. The @file{.gcno}, and
-@file{.gcda} data files are searched for using this option. If a directory
-is specified, the data files are in that directory and named after the
-input file name, without its extension. If a file is specified here,
-the data files are named after that file, without its extension.
-
-@item -s @var{directory}
-@itemx --source-prefix @var{directory}
-A prefix for source file names to remove when generating the output
-coverage files. This option is useful when building in a separate
-directory, and the pathname to the source directory is not wanted when
-determining the output file names. Note that this prefix detection is
-applied before determining whether the source file is absolute.
-
-@item -u
-@itemx --unconditional-branches
-When branch probabilities are given, include those of unconditional branches.
-Unconditional branches are normally not interesting.
-
-@item -d
-@itemx --display-progress
-Display the progress on the standard output.
+@item -h
+@itemx --help
+Display help about using @command{gcov} (on the standard output), and
+exit without doing any further processing.
@item -i
@itemx --intermediate-format
@@ -274,11 +215,75 @@ lcount:26,1
branch:28,nottaken
@end smallexample
+@item -l
+@itemx --long-file-names
+Create long file names for included source files. For example, if the
+header file @file{x.h} contains code, and was included in the file
+@file{a.c}, then running @command{gcov} on the file @file{a.c} will
+produce an output file called @file{a.c##x.h.gcov} instead of
+@file{x.h.gcov}. This can be useful if @file{x.h} is included in
+multiple source files and you want to see the individual
+contributions. If you use the @samp{-p} option, both the including
+and included file names will be complete path names.
+
@item -m
@itemx --demangled-names
Display demangled function names in output. The default is to show
mangled function names.
+@item -n
+@itemx --no-output
+Do not create the @command{gcov} output file.
+
+@item -o @var{directory|file}
+@itemx --object-directory @var{directory}
+@itemx --object-file @var{file}
+Specify either the directory containing the gcov data files, or the
+object path name. The @file{.gcno}, and
+@file{.gcda} data files are searched for using this option. If a directory
+is specified, the data files are in that directory and named after the
+input file name, without its extension. If a file is specified here,
+the data files are named after that file, without its extension.
+
+@item -p
+@itemx --preserve-paths
+Preserve complete path information in the names of generated
+@file{.gcov} files. Without this option, just the filename component is
+used. With this option, all directories are used, with @samp{/} characters
+translated to @samp{#} characters, @file{.} directory components
+removed and unremoveable @file{..}
+components renamed to @samp{^}. This is useful if sourcefiles are in several
+different directories.
+
+@item -r
+@itemx --relative-only
+Only output information about source files with a relative pathname
+(after source prefix elision). Absolute paths are usually system
+header files and coverage of any inline functions therein is normally
+uninteresting.
+
+@item -s @var{directory}
+@itemx --source-prefix @var{directory}
+A prefix for source file names to remove when generating the output
+coverage files. This option is useful when building in a separate
+directory, and the pathname to the source directory is not wanted when
+determining the output file names. Note that this prefix detection is
+applied before determining whether the source file is absolute.
+
+@item -u
+@itemx --unconditional-branches
+When branch probabilities are given, include those of unconditional branches.
+Unconditional branches are normally not interesting.
+
+@item -v
+@itemx --version
+Display the @command{gcov} version number (on the standard output),
+and exit without doing any further processing.
+
+@item -w
+@itemx --verbose
+Print verbose informations related to basic blocks and arcs.
+
@item -x
@itemx --hash-filenames
By default, gcov uses the full pathname of the source files to to create
diff --git a/gcc/gcov-dump.c b/gcc/gcov-dump.c
index 91c48668c82..3bf16ab2c53 100644
--- a/gcc/gcov-dump.c
+++ b/gcc/gcov-dump.c
@@ -132,9 +132,9 @@ print_usage (void)
printf ("Usage: gcov-dump [OPTION] ... gcovfiles\n");
printf ("Print coverage file contents\n");
printf (" -h, --help Print this help\n");
- printf (" -v, --version Print version number\n");
printf (" -l, --long Dump record contents too\n");
printf (" -p, --positions Dump record positions\n");
+ printf (" -v, --version Print version number\n");
printf (" -w, --working-sets Dump working set computed from summary\n");
printf ("\nFor bug reporting instructions, please see:\n%s.\n",
bug_report_url);
diff --git a/gcc/gcov-tool.c b/gcc/gcov-tool.c
index 80c08354857..74e77b90d72 100644
--- a/gcc/gcov-tool.c
+++ b/gcc/gcov-tool.c
@@ -173,8 +173,8 @@ print_merge_usage_message (int error_p)
FILE *file = error_p ? stderr : stdout;
fnotice (file, " merge [options] <dir1> <dir2> Merge coverage file contents\n");
- fnotice (file, " -v, --verbose Verbose mode\n");
fnotice (file, " -o, --output <dir> Output directory\n");
+ fnotice (file, " -v, --verbose Verbose mode\n");
fnotice (file, " -w, --weight <w1,w2> Set weights (float point values)\n");
}
@@ -267,10 +267,10 @@ print_rewrite_usage_message (int error_p)
FILE *file = error_p ? stderr : stdout;
fnotice (file, " rewrite [options] <dir> Rewrite coverage file contents\n");
- fnotice (file, " -v, --verbose Verbose mode\n");
+ fnotice (file, " -n, --normalize <int64_t> Normalize the profile\n");
fnotice (file, " -o, --output <dir> Output directory\n");
fnotice (file, " -s, --scale <float or simple-frac> Scale the profile counters\n");
- fnotice (file, " -n, --normalize <int64_t> Normalize the profile\n");
+ fnotice (file, " -v, --verbose Verbose mode\n");
}
static const struct option rewrite_options[] =
@@ -417,12 +417,12 @@ print_overlap_usage_message (int error_p)
FILE *file = error_p ? stderr : stdout;
fnotice (file, " overlap [options] <dir1> <dir2> Compute the overlap of two profiles\n");
- fnotice (file, " -v, --verbose Verbose mode\n");
- fnotice (file, " -h, --hotonly Only print info for hot objects/functions\n");
fnotice (file, " -f, --function Print function level info\n");
fnotice (file, " -F, --fullname Print full filename\n");
+ fnotice (file, " -h, --hotonly Only print info for hot objects/functions\n");
fnotice (file, " -o, --object Print object level info\n");
fnotice (file, " -t <float>, --hot_threshold <float> Set the threshold for hotness\n");
+ fnotice (file, " -v, --verbose Verbose mode\n");
}
diff --git a/gcc/gcov.c b/gcc/gcov.c
index a52c6404cb1..1fb505898a3 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -655,13 +655,13 @@ print_usage (int error_p)
fnotice (file, "Usage: gcov [OPTION...] SOURCE|OBJ...\n\n");
fnotice (file, "Print code coverage information.\n\n");
- fnotice (file, " -h, --help Print this help, then exit\n");
fnotice (file, " -a, --all-blocks Show information for every basic block\n");
fnotice (file, " -b, --branch-probabilities Include branch probabilities in output\n");
fnotice (file, " -c, --branch-counts Output counts of branches taken\n\
rather than percentages\n");
fnotice (file, " -d, --display-progress Display progress information\n");
fnotice (file, " -f, --function-summaries Output summaries for each function\n");
+ fnotice (file, " -h, --help Print this help, then exit\n");
fnotice (file, " -i, --intermediate-format Output .gcov file in intermediate text format\n");
fnotice (file, " -l, --long-file-names Use long output file names for included\n\
source files\n");
--
2.13.1
>From b944db6373e4b820ad6cf7c9abe59e86387c7427 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 28 Apr 2017 12:51:22 +0000
Subject: [PATCH 02/12] Backport r247375
gcc/ChangeLog:
2017-04-28 Martin Liska <mliska@suse.cz>
PR gcov-profile/53915
* gcov.c (format_gcov): Print 'NAN %' when top > bottom.
---
gcc/gcov.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/gcc/gcov.c b/gcc/gcov.c
index bb26a1a9787..a52c6404cb1 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -1959,6 +1959,13 @@ format_gcov (gcov_type top, gcov_type bottom, int dp)
{
static char buffer[20];
+ /* Handle invalid values that would result in a misleading value. */
+ if (bottom != 0 && top > bottom && dp >= 0)
+ {
+ sprintf (buffer, "NAN %%");
+ return buffer;
+ }
+
if (dp >= 0)
{
float ratio = bottom ? (float)top / bottom : 0;
--
2.13.1
>From b805004b661f694460827035b1f1290777e91202 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 28 Apr 2017 12:50:08 +0000
Subject: [PATCH 01/12] Backport r247371
gcc/ChangeLog:
2017-04-28 Martin Liska <mliska@suse.cz>
PR driver/56469
* coverage.c (coverage_remove_note_file): New function.
* coverage.h: Declare the function.
* toplev.c (finalize): Clean if an error has been seen.
---
gcc/coverage.c | 12 ++++++++++++
gcc/coverage.h | 1 +
gcc/toplev.c | 3 +++
3 files changed, 16 insertions(+)
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 0a949c3a9f7..53e379b3295 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -731,6 +731,18 @@ coverage_end_function (unsigned lineno_checksum, unsigned cfg_checksum)
}
}
+/* Remove coverage file if opened. */
+
+void
+coverage_remove_note_file (void)
+{
+ if (bbg_file_name)
+ {
+ gcov_close ();
+ unlink (bbg_file_name);
+ }
+}
+
/* Build a coverage variable of TYPE for function FN_DECL. If COUNTER
>= 0 it is a counter array, otherwise it is the function structure. */
diff --git a/gcc/coverage.h b/gcc/coverage.h
index cde6aef1d76..90454c0ecba 100644
--- a/gcc/coverage.h
+++ b/gcc/coverage.h
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
extern void coverage_init (const char *);
extern void coverage_finish (void);
+extern void coverage_remove_note_file (void);
/* Start outputting coverage information for the current
function. */
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 54a4f05c9a1..f1384fc2fda 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1915,6 +1915,9 @@ finalize (bool no_backend)
stack_usage_file = NULL;
}
+ if (seen_error ())
+ coverage_remove_note_file ();
+
if (!no_backend)
{
statistics_fini ();
--
2.13.1