aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2016-05-30 18:13:12 +0000
committerAndi Kleen <ak@gcc.gnu.org>2016-05-30 18:13:12 +0000
commit1bba63a77e3ed0a3420eaa905f753614d5ec99d5 (patch)
tree1985bc8a06c27e925e000ac5e9c9b1bc6053499a
parent53803093d096611166267de1390d0318592944e2 (diff)
downloadgcc-1bba63a77e3ed0a3420eaa905f753614d5ec99d5.zip
gcc-1bba63a77e3ed0a3420eaa905f753614d5ec99d5.tar.gz
gcc-1bba63a77e3ed0a3420eaa905f753614d5ec99d5.tar.bz2
Don't cause ICEs when auto profile file is not found with checking
Currently, on a checking enabled compiler when -fauto-profile does not find the profile feedback file it errors out with assertation failures. Add proper errors for this case. gcc/: 2016-05-30 Andi Kleen <ak@linux.intel.com> * auto-profile.c (read_profile): Replace asserts with errors when file does not exist. * gcov-io.c (gcov_read_words): Dito. From-SVN: r236894
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/auto-profile.c32
-rw-r--r--gcc/gcov-io.c4
3 files changed, 34 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index be1d4b1..c6a3226 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2016-05-30 Andi Kleen <ak@linux.intel.com>
+
+ * auto-profile.c (read_profile): Replace asserts with errors
+ when file does not exist.
+ * gcov-io.c (gcov_read_words): Dito.
+
2016-05-30 Jan Hubicka <hubicka@ucw.cz>
* tree-cfg.c (print_loop): Print likely upper bounds.
diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index cd82ab4..00b3687 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -884,16 +884,25 @@ static void
read_profile (void)
{
if (gcov_open (auto_profile_file, 1) == 0)
- error ("Cannot open profile file %s.", auto_profile_file);
+ {
+ error ("Cannot open profile file %s.", auto_profile_file);
+ return;
+ }
if (gcov_read_unsigned () != GCOV_DATA_MAGIC)
- error ("AutoFDO profile magic number does not mathch.");
+ {
+ error ("AutoFDO profile magic number does not match.");
+ return;
+ }
/* Skip the version number. */
unsigned version = gcov_read_unsigned ();
if (version != AUTO_PROFILE_VERSION)
- error ("AutoFDO profile version %u does match %u.",
- version, AUTO_PROFILE_VERSION);
+ {
+ error ("AutoFDO profile version %u does match %u.",
+ version, AUTO_PROFILE_VERSION);
+ return;
+ }
/* Skip the empty integer. */
gcov_read_unsigned ();
@@ -901,19 +910,28 @@ read_profile (void)
/* string_table. */
afdo_string_table = new string_table ();
if (!afdo_string_table->read())
- error ("Cannot read string table from %s.", auto_profile_file);
+ {
+ error ("Cannot read string table from %s.", auto_profile_file);
+ return;
+ }
/* autofdo_source_profile. */
afdo_source_profile = autofdo_source_profile::create ();
if (afdo_source_profile == NULL)
- error ("Cannot read function profile from %s.", auto_profile_file);
+ {
+ error ("Cannot read function profile from %s.", auto_profile_file);
+ return;
+ }
/* autofdo_module_profile. */
fake_read_autofdo_module_profile ();
/* Read in the working set. */
if (gcov_read_unsigned () != GCOV_TAG_AFDO_WORKING_SET)
- error ("Cannot read working set from %s.", auto_profile_file);
+ {
+ error ("Cannot read working set from %s.", auto_profile_file);
+ return;
+ }
/* Skip the length of the section. */
gcov_read_unsigned ();
diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c
index 17fcae0..95ead22 100644
--- a/gcc/gcov-io.c
+++ b/gcc/gcov-io.c
@@ -493,7 +493,9 @@ gcov_read_words (unsigned words)
const gcov_unsigned_t *result;
unsigned excess = gcov_var.length - gcov_var.offset;
- gcov_nonruntime_assert (gcov_var.mode > 0);
+ if (gcov_var.mode <= 0)
+ return NULL;
+
if (excess < words)
{
gcov_var.start += gcov_var.offset;