From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12424 invoked by alias); 21 Sep 2018 23:20:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 12401 invoked by uid 89); 21 Sep 2018 23:20:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_NUMSUBJECT,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=wiped, fprofile-use, 42188, fprofileuse X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Sep 2018 23:20:15 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w8LNJgwC134359; Fri, 21 Sep 2018 23:20:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : references : from : cc : to : message-id : date : mime-version : in-reply-to : content-type; s=corp-2018-07-02; bh=ezMXmYWNsCRfWGnAo95N/77OTyA3/uldvCR70uWoefw=; b=a+qjp7/1PEBOSFRynAHaKhRx5tAOkl2ms92ToGmv/3nDGz7fy+rmADu7b833pGysaGwE Wa16bGRBLMQtrdwYFV4uRIRDOSkBfz7xTbiC6N2WcAWYJYwQKMoTGkGrdmG+cb6XmTnt dW9b0t3bwD44sr7O+zit1SOxWNO57oRFb8DltaD7O/e7S6x6hAFqhONU6JA6YAQ/O0Oo cGyoVq27x0Bq/jMduEjhWAGLEGtxVtB51Lqj1hyZ+g147dAyDAyRjfI0ANAJzNj0Rql7 SIUIB5cC0lg4XX+PanWPg2VgnmmA3VPrD7Thm5IEXS5owVklU6OUNv3fqthEcINbCfZv 3w== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2mmkm25pk3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Sep 2018 23:20:12 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w8LNK6eq027811 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Sep 2018 23:20:07 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w8LNK6pE019715; Fri, 21 Sep 2018 23:20:06 GMT Received: from [10.159.139.235] (/10.159.139.235) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 21 Sep 2018 16:20:06 -0700 Subject: Re: [PATCH] PR86957 References: <6a2ea403-22c3-91f6-f826-29e186f21b91@suse.cz> <159a29c5-8f8b-4194-dbea-1c9bd414db3a@oracle.com> <7ed25f0a-10a8-3eca-c032-29e76054bfb6@suse.cz> <20180917105249.GA49438@kam.mff.cuni.cz> From: Indu Bhagat Cc: gcc-patches@gcc.gnu.org To: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: Date: Fri, 21 Sep 2018 23:23:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20180917105249.GA49438@kam.mff.cuni.cz> Content-Type: multipart/mixed; boundary="------------DE4A450E982EF7D1B26A2524" X-SW-Source: 2018-09/txt/msg01277.txt.bz2 This is a multi-part message in MIME format. --------------DE4A450E982EF7D1B26A2524 Content-Type: text/plain; charset=iso-8859-2; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1085 Attached is the refreshed patch for trunk. After commit 264462 (Remove arc profile histogram in non-LTO mode.), the API of get_coverage_counts was changed a bit. So the main difference between the current version of my patch from the previous one is that : Now I use + if (counter == GCOV_COUNTER_ARCS) + warning_at (DECL_SOURCE_LOCATION (current_function_decl), + OPT_Wmissing_profile, + "profile for function %qD not found in profile data", + current_function_decl); instead of + if (summary) + warning_at (DECL_SOURCE_LOCATION (current_function_decl), + OPT_Wmissing_profile, + "profile for function %qD not found in profile data", + current_function_decl); to warn about missing profile of a function only once (get_coverage_counts is called from two diff flows : getting exec counts for arc counter and computing histogram for other other counters) I am not sure of any better way to avoid superfluous warnings per function. Is the patch OK ? --------------DE4A450E982EF7D1B26A2524 Content-Type: text/x-patch; name="pr86957-ver3.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr86957-ver3.patch" Content-length: 6336 diff --git a/gcc/common.opt b/gcc/common.opt index ef6a630..53aac19 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -811,6 +811,10 @@ Wcoverage-mismatch Common Var(warn_coverage_mismatch) Init(1) Warning Warn in case profiles in -fprofile-use do not match. +Wmissing-profile +Common Var(warn_missing_profile) Init(1) Warning +Warn in case profiles in -fprofile-use do not exist. + Wvector-operation-performance Common Var(warn_vector_operation_performance) Warning Warn when a vector operation is compiled outside the SIMD. diff --git a/gcc/coverage.c b/gcc/coverage.c index 26cce2b..4b6df8a 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -304,16 +304,23 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum, { static int warned = 0; - if (!warned++ && dump_enabled_p ()) + if (!warned++) { - dump_user_location_t loc - = dump_user_location_t::from_location_t (input_location); - dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, + warning (OPT_Wmissing_profile, + "%qs profile count data file not found", + da_file_name); + if (dump_enabled_p ()) + { + dump_user_location_t loc + = dump_user_location_t::from_location_t (input_location); + dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, + "file %s not found\n", + da_file_name); + dump_printf (MSG_OPTIMIZED_LOCATIONS, (flag_guess_branch_prob - ? "file %s not found, execution counts estimated\n" - : "file %s not found, execution counts assumed to " - "be zero\n"), - da_file_name); + ? "execution counts estimated\n" + : "execution counts assumed to be zero\n")); + } } return NULL; } @@ -327,10 +334,17 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum, elt.ctr = counter; entry = counts_hash->find (&elt); if (!entry) - /* The function was not emitted, or is weak and not chosen in the - final executable. Silently fail, because there's nothing we - can do about it. */ - return NULL; + { + if (counter == GCOV_COUNTER_ARCS) + warning_at (DECL_SOURCE_LOCATION (current_function_decl), + OPT_Wmissing_profile, + "profile for function %qD not found in profile data", + current_function_decl); + /* The function was not emitted, or is weak and not chosen in the + final executable. Silently fail, because there's nothing we + can do about it. */ + return NULL; + } if (entry->cfg_checksum != cfg_checksum) { diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index abbd9ec..ed56af3 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -315,7 +315,7 @@ Objective-C and Objective-C++ Dialects}. -Wlogical-op -Wlogical-not-parentheses -Wlong-long @gol -Wmain -Wmaybe-uninitialized -Wmemset-elt-size -Wmemset-transposed-args @gol -Wmisleading-indentation -Wmissing-attributes -Wmissing-braces @gol --Wmissing-field-initializers -Wmissing-include-dirs @gol +-Wmissing-field-initializers -Wmissing-include-dirs -Wmissing-profile @gol -Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare @gol -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} @gol -Wnull-dereference -Wodr -Wno-overflow -Wopenmp-simd @gol @@ -4218,8 +4218,8 @@ Warn about an invalid memory access that is found by Pointer Bounds Checker @opindex Wcoverage-mismatch Warn if feedback profiles do not match when using the @option{-fprofile-use} option. -If a source file is changed between compiling with @option{-fprofile-gen} and -with @option{-fprofile-use}, the files with the profile feedback can fail +If a source file is changed between compiling with @option{-fprofile-generate} +and with @option{-fprofile-use}, the files with the profile feedback can fail to match the source file and GCC cannot use the profile feedback information. By default, this warning is enabled and is treated as an error. @option{-Wno-coverage-mismatch} can be used to disable the @@ -4823,6 +4823,23 @@ This warning is enabled by @option{-Wall}. @opindex Wno-missing-include-dirs Warn if a user-supplied include directory does not exist. +@item -Wmissing-profile +@opindex Wmissing-profile +@opindex Wno-missing-profile +Warn if feedback profiles are missing when using the +@option{-fprofile-use} option. +This option diagnoses those cases where a new function or a new file is added +to the user code between compiling with @option{-fprofile-generate} and with +@option{-fprofile-use}, without regenerating the profiles. In these cases, the +profile feedback data files do not contain any profile feedback information for +the newly added function or file respectively. Also, in the case when profile +count data (.gcda) files are wiped out, GCC cannot use any profile feedback +information. In all these cases, warnings are issued to inform the user that a +profile generation step is due. @option{-Wno-missing-profile} can be used to +disable the warning. Ignoring the warning can result in poorly optimized code. +Completely disabling the warning is not recommended and should be done only +when non-existent profile data is justified. + @item -Wmultistatement-macros @opindex Wmultistatement-macros @opindex Wno-multistatement-macros @@ -9920,8 +9937,9 @@ Before you can use this option, you must first generate profiling information. By default, GCC emits an error message if the feedback profiles do not match the source code. This error can be turned into a warning by using -@option{-Wcoverage-mismatch}. Note this may result in poorly optimized -code. +@option{-Wno-error=coverage-mismatch}. Note this may result in poorly +optimized code. Additionally, by default, GCC also emits a warning message if +the feedback profiles do not exist (See @option{-Wmissing-profile}). If @var{path} is specified, GCC looks at the @var{path} to find the profile feedback data files. See @option{-fprofile-dir}. diff --git a/gcc/testsuite/gcc.dg/Wmissing-profile.c b/gcc/testsuite/gcc.dg/Wmissing-profile.c new file mode 100644 index 0000000..6ef1ac1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wmissing-profile.c @@ -0,0 +1,5 @@ +/* PR gcov-profile/86957 */ +/* { dg-do compile } */ +/* { dg-options "-fprofile-use" } */ + +void foo () { } /* { dg-warning "profile count data file not found" } */ --------------DE4A450E982EF7D1B26A2524--