This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.

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..b62a0d626d94 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:
-- 
Markus


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]