Hi. There's another bunch of backports to GCC 7 branch I've just tested and bootstrapped.
Martin
>From 6a918e72d251dd4e2aa8b2c9643f857ceef3997d Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Tue, 31 Oct 2017 11:55:19 +0000 Subject: [PATCH 4/7] Backport r254257 gcc/ChangeLog: 2017-10-31 Martin Liska <mli...@suse.cz> PR gcov-profile/82633 * doc/gcov.texi: Document -fkeep-{static,inline}-functions and their interaction with GCOV infrastructure. --- gcc/configure | 4 ++-- gcc/configure.ac | 4 ++-- gcc/doc/gcov.texi | 7 +++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gcc/doc/gcov.texi b/gcc/doc/gcov.texi index 706aa6cf0b0..88b8d6d9071 100644 --- a/gcc/doc/gcov.texi +++ b/gcc/doc/gcov.texi @@ -328,6 +328,13 @@ handlers, respectively. Given @samp{-a} option, unexecuted blocks are marked @samp{$$$$$} or @samp{%%%%%}, depending on whether a basic block is reachable via non-exceptional or exceptional paths. +Note that GCC can completely remove the bodies of functions that are +not needed -- for instance if they are inlined everywhere. Such functions +are marked with @samp{-}, which can be confusing. +Use the @option{-fkeep-inline-functions} and @option{-fkeep-static-functions} +options to retain these functions and +allow gcov to properly show their @var{execution_count}. + Some lines of information at the start have @var{line_number} of zero. These preamble lines are of the form -- 2.14.3
>From 1ffe6cb8c9e9b6474616b63bc19e14f57a3bcf04 Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Tue, 21 Nov 2017 13:39:14 +0000 Subject: [PATCH 7/7] Backport r255001 gcc/ChangeLog: 2017-11-21 Martin Liska <mli...@suse.cz> PR rtl-optimization/82044 PR tree-optimization/82042 * dse.c (check_mem_read_rtx): Check for overflow. --- gcc/dse.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/dse.c b/gcc/dse.c index f87dd50024e..6cd1b83d802 100644 --- a/gcc/dse.c +++ b/gcc/dse.c @@ -1978,6 +1978,12 @@ check_mem_read_rtx (rtx *loc, bb_info_t bb_info) else width = GET_MODE_SIZE (GET_MODE (mem)); + if (offset > HOST_WIDE_INT_MAX - width) + { + clear_rhs_from_active_local_stores (); + return; + } + read_info = read_info_type_pool.allocate (); read_info->group_id = group_id; read_info->mem = mem; -- 2.14.3
>From d9b29ea9aedb3ccc88ee66d71999ab12bf6ee498 Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed, 8 Nov 2017 11:45:35 +0000 Subject: [PATCH 6/7] Backport r254524 gcc/ChangeLog: 2017-11-08 Martin Liska <mli...@suse.cz> * gimplify.c (expand_FALLTHROUGH_r): Simplify usage of gimple_call_internal_p. --- gcc/gimplify.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gcc/gimplify.c b/gcc/gimplify.c index c0ba76aefdc..5264a4f3d40 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2203,8 +2203,7 @@ expand_FALLTHROUGH_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p, while (!gsi_end_p (gsi2)) { stmt = gsi_stmt (gsi2); - enum gimple_code gc = gimple_code (stmt); - if (gc == GIMPLE_LABEL) + if (gimple_code (stmt) == GIMPLE_LABEL) { tree label = gimple_label_label (as_a <glabel *> (stmt)); if (gimple_has_location (stmt) && DECL_ARTIFICIAL (label)) @@ -2213,8 +2212,7 @@ expand_FALLTHROUGH_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p, break; } } - else if (gc == GIMPLE_CALL - && gimple_call_internal_p (stmt, IFN_ASAN_MARK)) + else if (gimple_call_internal_p (stmt, IFN_ASAN_MARK)) ; else /* Something other is not expected. */ -- 2.14.3
>From 0a31d813c6b12b7530affb9ad937c36d3b0b48ec Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed, 8 Nov 2017 08:17:30 +0000 Subject: [PATCH 5/7] Backport r254519 gcc/ChangeLog: 2017-11-08 Martin Liska <mli...@suse.cz> PR sanitizer/82792 * gimplify.c (expand_FALLTHROUGH_r): Skip IFN_ASAN_MARK. gcc/testsuite/ChangeLog: 2017-11-08 Martin Liska <mli...@suse.cz> PR sanitizer/82792 * g++.dg/asan/pr82792.C: New test. --- gcc/gimplify.c | 8 ++++++-- gcc/testsuite/g++.dg/asan/pr82792.C | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/asan/pr82792.C diff --git a/gcc/gimplify.c b/gcc/gimplify.c index e23aae91094..c0ba76aefdc 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2203,7 +2203,8 @@ expand_FALLTHROUGH_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p, while (!gsi_end_p (gsi2)) { stmt = gsi_stmt (gsi2); - if (gimple_code (stmt) == GIMPLE_LABEL) + enum gimple_code gc = gimple_code (stmt); + if (gc == GIMPLE_LABEL) { tree label = gimple_label_label (as_a <glabel *> (stmt)); if (gimple_has_location (stmt) && DECL_ARTIFICIAL (label)) @@ -2212,8 +2213,11 @@ expand_FALLTHROUGH_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p, break; } } + else if (gc == GIMPLE_CALL + && gimple_call_internal_p (stmt, IFN_ASAN_MARK)) + ; else - /* Something other than a label. That's not expected. */ + /* Something other is not expected. */ break; gsi_next (&gsi2); } diff --git a/gcc/testsuite/g++.dg/asan/pr82792.C b/gcc/testsuite/g++.dg/asan/pr82792.C new file mode 100644 index 00000000000..99f1c35328c --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/pr82792.C @@ -0,0 +1,32 @@ +/* PR sanitizer/82792 */ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=address" } */ + +extern int +test (int i, int j) +{ + long c; + (c) = 1; + switch (i) + { + case 1: + if (j) + { + c = 1; + } + goto default_case; + case 2: + { + if (j) + { + c = 0; + } + } + __attribute ((fallthrough)); + default_case: + default: + c = 0; + break; + } + return 0; +} -- 2.14.3
>From 68feec0367c57eb1778e58d0cbe3b0949f1d9a9f Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Thu, 19 Oct 2017 11:08:28 +0000 Subject: [PATCH 3/7] Backport r253886 gcc/ChangeLog: 2017-10-19 Martin Liska <mli...@suse.cz> PR driver/81829 * file-find.c (remove_prefix): Remove. * file-find.h (remove_prefix): Likewise. * gcc-ar.c: Remove smartness of lookup. --- gcc/file-find.c | 35 ----------------------------------- gcc/file-find.h | 1 - gcc/gcc-ar.c | 8 -------- 3 files changed, 44 deletions(-) diff --git a/gcc/file-find.c b/gcc/file-find.c index b072a4993d7..b5a1fe8494e 100644 --- a/gcc/file-find.c +++ b/gcc/file-find.c @@ -208,38 +208,3 @@ prefix_from_string (const char *p, struct path_prefix *pprefix) } free (nstore); } - -void -remove_prefix (const char *prefix, struct path_prefix *pprefix) -{ - struct prefix_list *remove, **prev, **remove_prev = NULL; - int max_len = 0; - - if (pprefix->plist) - { - prev = &pprefix->plist; - for (struct prefix_list *pl = pprefix->plist; pl->next; pl = pl->next) - { - if (strcmp (prefix, pl->prefix) == 0) - { - remove = pl; - remove_prev = prev; - continue; - } - - int l = strlen (pl->prefix); - if (l > max_len) - max_len = l; - - prev = &pl; - } - - if (remove_prev) - { - *remove_prev = remove->next; - free (remove); - } - - pprefix->max_len = max_len; - } -} diff --git a/gcc/file-find.h b/gcc/file-find.h index 8f49a3af273..407feba26e7 100644 --- a/gcc/file-find.h +++ b/gcc/file-find.h @@ -41,7 +41,6 @@ extern void find_file_set_debug (bool); extern char *find_a_file (struct path_prefix *, const char *, int); extern void add_prefix (struct path_prefix *, const char *); extern void add_prefix_begin (struct path_prefix *, const char *); -extern void remove_prefix (const char *prefix, struct path_prefix *); extern void prefix_from_env (const char *, struct path_prefix *); extern void prefix_from_string (const char *, struct path_prefix *); diff --git a/gcc/gcc-ar.c b/gcc/gcc-ar.c index 78d2fc1ad30..d5d80e042e5 100644 --- a/gcc/gcc-ar.c +++ b/gcc/gcc-ar.c @@ -194,14 +194,6 @@ main (int ac, char **av) #ifdef CROSS_DIRECTORY_STRUCTURE real_exe_name = concat (target_machine, "-", PERSONALITY, NULL); #endif - /* Do not search original location in the same folder. */ - char *exe_folder = lrealpath (av[0]); - exe_folder[strlen (exe_folder) - strlen (lbasename (exe_folder))] = '\0'; - char *location = concat (exe_folder, PERSONALITY, NULL); - - if (access (location, X_OK) == 0) - remove_prefix (exe_folder, &path); - exe_name = find_a_file (&path, real_exe_name, X_OK); if (!exe_name) { -- 2.14.3
>From ac675c9f0124e87a5f5d22c324e236f318410fdd Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed, 18 Oct 2017 08:14:47 +0000 Subject: [PATCH 2/7] Backport r253845 gcc/ChangeLog: 2017-10-18 Martin Liska <mli...@suse.cz> PR sanitizer/82545 * asan.c (asan_expand_poison_ifn): Do not put gimple stmt on an abnormal edge. gcc/testsuite/ChangeLog: 2017-10-18 Martin Liska <mli...@suse.cz> PR sanitizer/82545 * gcc.dg/asan/pr82545.c: New test. --- gcc/asan.c | 4 ++++ gcc/testsuite/gcc.dg/asan/pr82545.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/asan/pr82545.c diff --git a/gcc/asan.c b/gcc/asan.c index fa48f789082..ddac31b9db6 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -3161,6 +3161,10 @@ asan_expand_poison_ifn (gimple_stmt_iterator *iter, { edge e = gimple_phi_arg_edge (phi, i); + /* Do not insert on an edge we can't split. */ + if (e->flags & EDGE_ABNORMAL) + continue; + if (call_to_insert == NULL) call_to_insert = gimple_copy (call); diff --git a/gcc/testsuite/gcc.dg/asan/pr82545.c b/gcc/testsuite/gcc.dg/asan/pr82545.c new file mode 100644 index 00000000000..8870db3653f --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr82545.c @@ -0,0 +1,17 @@ +/* PR sanitizer/82545. */ +/* { dg-do compile } */ + +extern void c(int); +extern void d(void); + +void *buf[5]; + +void a(void) { + { + int b; + &b; + __builtin_setjmp(buf); + c(b); + } + d(); +} -- 2.14.3
>From 49a67ca20dd515e03bf6ba663e0d84f1018b57a6 Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed, 11 Oct 2017 12:30:03 +0000 Subject: [PATCH 1/7] Backport r253639 gcc/ChangeLog: 2017-10-11 Martin Liska <mli...@suse.cz> * print-rtl.c (print_insn): Move declaration of idbuf to same scope as name. --- gcc/print-rtl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c index 30fd7597450..849214305f4 100644 --- a/gcc/print-rtl.c +++ b/gcc/print-rtl.c @@ -1792,11 +1792,11 @@ print_insn (pretty_printer *pp, const rtx_insn *x, int verbose) case DEBUG_INSN: { const char *name = "?"; + char idbuf[32]; if (DECL_P (INSN_VAR_LOCATION_DECL (x))) { tree id = DECL_NAME (INSN_VAR_LOCATION_DECL (x)); - char idbuf[32]; if (id) name = IDENTIFIER_POINTER (id); else if (TREE_CODE (INSN_VAR_LOCATION_DECL (x)) -- 2.14.3