On 07/21/2016 10:56 AM, Richard Biener wrote: > On Wed, Jul 20, 2016 at 3:34 PM, Martin Liška <mli...@suse.cz> wrote: >> Hi. >> >> Following patch addresses ICE which happens when coverage.c computes checksum >> of a function w/o xloc.file. My patch assumes it's a valid state having a >> function >> w/o xloc.file, which is situation exposed by cilkplus functions. >> >> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. >> >> Ready to be installed? > > Yes. > > I think we should try to do better when assigning a location to new > function decls, > that is, avoid UNKNOWN_LOCATION and at least have some file information. > For cilk-plus functions using the decl location of the original > function might work. > > That said, a safe-guard against this case is ok, thus the patch is as well. > > Richard.
Thanks for review, I'm testing v2 where I copy SOURCE_LOCATION from the current_function_decl. I'll install the patch after patch testing will pass. M. > >> Martin
>From 6a456aa0a1f3e7b1e702ecc87642cede92048c0e Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Wed, 20 Jul 2016 09:54:12 +0200 Subject: [PATCH] Consider functions with xloc.file == NULL (PR gcov-profile/69028) gcc/testsuite/ChangeLog: 2016-07-20 Martin Liska <mli...@suse.cz> PR gcov-profile/69028 PR gcov-profile/62047 * g++.dg/cilk-plus/pr69028.C: New test. gcc/c-family/ChangeLog: 2016-07-22 Martin Liska <mli...@suse.cz> * cilk.c (create_cilk_helper_decl): Set location of a new decl to the current_function_decl. gcc/ChangeLog: 2016-07-20 Martin Liska <mli...@suse.cz> * coverage.c (coverage_compute_lineno_checksum): Do not calculate checksum for fns w/o xloc.file. (coverage_compute_profile_id): Likewise. --- gcc/c-family/cilk.c | 5 +++-- gcc/coverage.c | 6 ++++-- gcc/testsuite/g++.dg/cilk-plus/pr69028.C | 13 +++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cilk-plus/pr69028.C diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c index 8f34cd6..39781c4 100644 --- a/gcc/c-family/cilk.c +++ b/gcc/c-family/cilk.c @@ -312,8 +312,9 @@ create_cilk_helper_decl (struct wrapper_data *wd) gcc_unreachable (); clean_symbol_name (name); - tree fndecl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, - get_identifier (name), wd->fntype); + + tree fndecl = build_decl (DECL_SOURCE_LOCATION (current_function_decl), + FUNCTION_DECL, get_identifier (name), wd->fntype); TREE_PUBLIC (fndecl) = 0; TREE_STATIC (fndecl) = 1; diff --git a/gcc/coverage.c b/gcc/coverage.c index 67cc908..d4d371e 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -553,7 +553,8 @@ coverage_compute_lineno_checksum (void) = expand_location (DECL_SOURCE_LOCATION (current_function_decl)); unsigned chksum = xloc.line; - chksum = coverage_checksum_string (chksum, xloc.file); + if (xloc.file) + chksum = coverage_checksum_string (chksum, xloc.file); chksum = coverage_checksum_string (chksum, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl))); @@ -580,7 +581,8 @@ coverage_compute_profile_id (struct cgraph_node *n) bool use_name_only = (PARAM_VALUE (PARAM_PROFILE_FUNC_INTERNAL_ID) == 0); chksum = (use_name_only ? 0 : xloc.line); - chksum = coverage_checksum_string (chksum, xloc.file); + if (xloc.file) + chksum = coverage_checksum_string (chksum, xloc.file); chksum = coverage_checksum_string (chksum, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (n->decl))); if (!use_name_only && first_global_object_name) diff --git a/gcc/testsuite/g++.dg/cilk-plus/pr69028.C b/gcc/testsuite/g++.dg/cilk-plus/pr69028.C new file mode 100644 index 0000000..31542f3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/pr69028.C @@ -0,0 +1,13 @@ +// PR c++/69028 +// { dg-require-effective-target c++11 } +// { dg-options "-fcilkplus -fprofile-arcs" } + +void parallel() +{ +} + +int main() +{ + _Cilk_spawn parallel(); + _Cilk_sync; +} -- 2.9.0