diff mbox

[PATCHv2,LTO/PGO] Warn when both -flto and -fprofile-generate are enabled

Message ID 20140402120203.GA280@x4
State New
Headers show

Commit Message

Markus Trippelsdorf April 2, 2014, 12:02 p.m. UTC
It is a common mistake to enable both -flto and -fprofile-generate when
building projects. This is not a good idea, because memory use will
skyrocket due to instrumentation. So just warn the user.

OK for next stage1?

2014-04-02  Markus Trippelsdorf  <markus@trippelsdorf.de>

	* common.opt (fprofile-generate): Add flag.
	* opts.c (finish_options): Add new warning.
	(common_handle_option): Set flag.

Comments

Rainer Orth April 2, 2014, 12:10 p.m. UTC | #1
Markus Trippelsdorf <markus@trippelsdorf.de> writes:

> diff --git a/gcc/opts.c b/gcc/opts.c
> index fdc903f9271a..581d2e948483 100644
> --- a/gcc/opts.c
> +++ b/gcc/opts.c
> @@ -833,6 +833,9 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
>  	error_at (loc, "only one -flto-partition value can be specified");
>      }
>  
> +  if (opts->x_flag_generate_lto && opts->x_flag_profile_generate)
> +    warning_at (loc, 0, "enabling both -fprofile-generate and -flto is a bad idea");

This warning is not very helpful in this form.  Rather say something
like `causes excessive memory consumption' if this is the problem.

	Rainer
diff mbox

Patch

diff --git a/gcc/common.opt b/gcc/common.opt
index 62c72f0d2fbf..61e9adfa0df5 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1689,7 +1689,7 @@  Common Report Var(flag_profile_correction)
 Enable correction of flow inconsistent profile data input
 
 fprofile-generate
-Common
+Common Var(flag_profile_generate)
 Enable common options for generating profile info for profile feedback directed optimizations
 
 fprofile-generate=
diff --git a/gcc/opts.c b/gcc/opts.c
index fdc903f9271a..581d2e948483 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -833,6 +833,9 @@  finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
 	error_at (loc, "only one -flto-partition value can be specified");
     }
 
+  if (opts->x_flag_generate_lto && opts->x_flag_profile_generate)
+    warning_at (loc, 0, "enabling both -fprofile-generate and -flto is a bad idea");
+
   /* We initialize opts->x_flag_split_stack to -1 so that targets can set a
      default value if they choose based on other options.  */
   if (opts->x_flag_split_stack == -1)
@@ -1728,6 +1731,7 @@  common_handle_option (struct gcc_options *opts,
 
     case OPT_fprofile_generate_:
       opts->x_profile_data_prefix = xstrdup (arg);
+      opts->x_flag_profile_generate = true;
       value = true;
       /* No break here - do -fprofile-generate processing. */
     case OPT_fprofile_generate: