From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 40979 invoked by alias); 15 Sep 2018 23:28:21 -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 40967 invoked by uid 89); 15 Sep 2018 23:28:20 -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,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: userp2120.oracle.com Received: from userp2120.oracle.com (HELO userp2120.oracle.com) (156.151.31.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 15 Sep 2018 23:28:18 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w8FNOpcp099077; Sat, 15 Sep 2018 23:28:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : references : cc : from : message-id : date : mime-version : in-reply-to : content-type; s=corp-2018-07-02; bh=lIJVnoYW6PUHubHBm1rkHj0uNCkeiBM3e2ryxNajQRY=; b=2L8ZPmjN598MINUwY23Y7Bpfz70F1YnDIAL8RtCNFZIOkgyoMbCz9O/pPg6fwOj3d8jA YTudzbH7LuOh+EE95vgt7tD8DnghuhTvi7vLK+57UA5MpRs0hoPhdAa8t5omZotInCBw F205Krj9ZV6w8jJzZgh3Gt6HY4dB34Q8x82cseofv8KTvMLjqNRsKZwtlCbJYzbgCUJz TI6RIJB/dpEUIeJg2Z7DHivjxzBmx3qTDHVge4Mb4u99PcKGXhhqXLw32ALXlibJ+ETE 9nEaUxxPi9J6WEnveHO51cJF/i9aPcR1xxSr6ObTUSreBOKa2XSgb0xz/h0LxMma6QWn eQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2mgtqqhfvs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 15 Sep 2018 23:28:16 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w8FNSGkK018038 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 15 Sep 2018 23:28:16 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w8FNSFXn001775; Sat, 15 Sep 2018 23:28:15 GMT Received: from [192.168.0.17] (/96.49.21.152) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 15 Sep 2018 16:28:15 -0700 Subject: Re: [PATCH] PR86957 To: =?UTF-8?Q?Martin_Li=c5=a1ka?= , gcc-patches@gcc.gnu.org References: <6a2ea403-22c3-91f6-f826-29e186f21b91@suse.cz> Cc: Jan Hubicka From: Indu Bhagat Message-ID: <59766490-f3a7-20c7-0a61-e009caec96b6@oracle.com> Date: Sun, 16 Sep 2018 08:28: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: <6a2ea403-22c3-91f6-f826-29e186f21b91@suse.cz> Content-Type: multipart/mixed; boundary="------------0A9E77559E4AC3C42AC446DA" X-SW-Source: 2018-09/txt/msg00816.txt.bz2 This is a multi-part message in MIME format. --------------0A9E77559E4AC3C42AC446DA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-length: 1552 Thanks for the reviews. I have incorporated all but one (See below; its the change in the warning's brief summary in common.opt) in the patch. In this patch, 1. -Wmissing-profile is a warning by default and is ON by default with -fprofile-use 2. Attached pr86957-missing-profile-diagnostic-2 shows the warning messages 3. Added a testcase for warning in the case of missing profile feedback data file for a compilation unit Thanks gcc/ChangeLog: 2018-09-14 "Indu Bhagat" * common.opt: New warning option -Wmissing-profile. * coverage.c (get_coverage_counts): Add warning for missing .gcda file. * doc/invoke.texi: Document -Wmissing-profile. gcc/testsuite/ChangeLog: 2018-09-14 "Indu Bhagat" * gcc.dg/Wmissing-profile.c: New test. On 09/11/2018 02:21 AM, Martin Liška wrote: >> diff --git a/gcc/common.opt b/gcc/common.opt >> index ebc3ef4..d93ddca 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. > Maybe 'Want about missing profile for a function in -fprofile-use build.' ? > Since, Wmissing-profile also warns when feedback data file is missing for a compilation unit, the suggested text above will be more restrictive. So I did not change. --------------0A9E77559E4AC3C42AC446DA Content-Type: text/plain; charset=UTF-8; name="pr86957-missing-profile-diagnostic-2" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="pr86957-missing-profile-diagnostic-2" Content-length: 2758 W1Rlc3RjYXNlIDFdIE1pc3NpbmcgcHJvZmlsZSBkYXRhIGZpbGUgd2l0aCAt ZnByb2ZpbGUtdXNlLiBUaGUgc29ydC5jIGZpbGUgY29udGFpbnMgdHdvIGZ1 bmN0aW9ucyBtYWluKCkgYW5kIHN0b3AoKQoKZ2NjIC1jIHNvcnQuYyAtZnBy b2ZpbGUtdXNlIC1PMSAtZnByb2ZpbGUtZGlyPS9zY3JhdGNoL3VzZXIvZ2Nj LXRlbXAvZmRvL3Byb2ZkYXRhLwpzb3J0LmM6IEluIGZ1bmN0aW9uIOKAmG1h aW7igJk6CnNvcnQuYzoyOToxOiB3YXJuaW5nOiDigJgvc2NyYXRjaC91c2V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v bnMgZm9yIGZ1bmN0aW9uIOKAmGJ1YmJsZV9zb3J04oCZIGhhdmUgY2hhbmdl ZCwgdGhlIHByb2ZpbGUgZGF0YSBtYXkgYmUgb3V0IG9mIGRhdGUgWy1XZXJy b3I9Y292ZXJhZ2UtbWlzbWF0Y2hdCjIwIHwgdm9pZCBhZnRlcjEoKSB7IH0K ICAgfCBefn5+CmNjMTogc29tZSB3YXJuaW5ncyBiZWluZyB0cmVhdGVkIGFz IGVycm9ycwoK --------------0A9E77559E4AC3C42AC446DA Content-Type: text/x-patch; name="pr86957-ver2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr86957-ver2.patch" Content-length: 6364 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 bae6f5c..f9b54d8 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -341,16 +341,23 @@ get_coverage_counts (unsigned counter, unsigned expected, { 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; } @@ -364,10 +371,17 @@ get_coverage_counts (unsigned counter, unsigned expected, elt.ctr = counter; entry = counts_hash->find (&elt); if (!entry || !entry->summary.num) - /* 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 (summary) + 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 || entry->summary.num != expected) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index ec12711..072327a 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -314,7 +314,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 @@ -4211,8 +4211,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 @@ -4816,6 +4816,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 @@ -9905,8 +9922,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" } */ --------------0A9E77559E4AC3C42AC446DA--