summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2017-12-08 11:27:28 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2017-12-08 11:27:28 +0000
commita22775d88ce6926403f9738e32499f733da1990e (patch)
tree04b3b1dbe61a5e583aa434041886ebd77afd6abd
parent414384381b0bd97dc5980c0592fd02f6f419823a (diff)
downloadgcc-a22775d88ce6926403f9738e32499f733da1990e.tar.gz
* profile-count.c (profile_count::from_gcov_type): Move from
profile-count.h; handle overflow. * profile-count. (profile_count::from_gcov_type): Move offline. PR middle-end/83609 * gcc.c-torture/compile/pr83069.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255507 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/profile-count.c18
-rw-r--r--gcc/profile-count.h17
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr83069.c14
5 files changed, 49 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dcd1fb68533..f7fac96d27c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2017-12-08 Jan Hubicka <hubicka@ucw.cz>
+
+ PR middle-end/83609
+ * profile-count.c (profile_count::from_gcov_type): Move from
+ profile-count.h; handle overflow.
+ * profile-count.h (profile_count::from_gcov_type): Move offline.
+
2017-12-08 Segher Boessenkool <segher@kernel.crashing.org>
PR rtl-optimization/83304
diff --git a/gcc/profile-count.c b/gcc/profile-count.c
index 5d8e9c55913..3b106d3f3ca 100644
--- a/gcc/profile-count.c
+++ b/gcc/profile-count.c
@@ -327,3 +327,21 @@ profile_count::combine_with_ipa_count (profile_count ipa)
return this->global0 ();
return this->global0adjusted ();
}
+
+/* The profiling runtime uses gcov_type, which is usually 64bit integer.
+ Conversions back and forth are used to read the coverage and get it
+ into internal representation. */
+profile_count
+profile_count::from_gcov_type (gcov_type v)
+ {
+ profile_count ret;
+ gcc_checking_assert (v >= 0);
+ if (dump_file && v >= (gcov_type)max_count)
+ fprintf (dump_file,
+ "Capping gcov count %" PRId64 " to max_count %" PRId64 "\n",
+ (int64_t) v, (int64_t) max_count);
+ ret.m_val = MIN (v, (gcov_type)max_count);
+ ret.m_quality = profile_precise;
+ return ret;
+ }
+
diff --git a/gcc/profile-count.h b/gcc/profile-count.h
index 2ffa33f639c..75456ad3586 100644
--- a/gcc/profile-count.h
+++ b/gcc/profile-count.h
@@ -667,18 +667,6 @@ public:
return c;
}
- /* The profiling runtime uses gcov_type, which is usually 64bit integer.
- Conversions back and forth are used to read the coverage and get it
- into internal representation. */
- static profile_count from_gcov_type (gcov_type v)
- {
- profile_count ret;
- gcc_checking_assert (v >= 0 && (uint64_t) v <= max_count);
- ret.m_val = v;
- ret.m_quality = profile_precise;
- return ret;
- }
-
/* Conversion to gcov_type is lossy. */
gcov_type to_gcov_type () const
{
@@ -1083,6 +1071,11 @@ public:
global0. */
profile_count combine_with_ipa_count (profile_count ipa);
+ /* The profiling runtime uses gcov_type, which is usually 64bit integer.
+ Conversions back and forth are used to read the coverage and get it
+ into internal representation. */
+ static profile_count from_gcov_type (gcov_type v);
+
/* LTO streaming support. */
static profile_count stream_in (struct lto_input_block *);
void stream_out (struct output_block *);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3b1a7e29111..cae9220a63d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-12-08 Jan Hubicka <hubicka@ucw.cz>
+
+ PR middle-end/83609
+ * gcc.c-torture/compile/pr83069.c: New testcase.
+
2017-12-08 Richard Biener <rguenther@suse.de>
PR tree-optimization/81303
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr83069.c b/gcc/testsuite/gcc.c-torture/compile/pr83069.c
new file mode 100644
index 00000000000..addb2df765b
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr83069.c
@@ -0,0 +1,14 @@
+#define MAX 98
+
+void foo (unsigned long *res, unsigned long in)
+{
+ for (unsigned long a = 0; a < MAX; a++)
+ for (unsigned long b = 0; b < MAX; b++)
+ for (unsigned long c = 0; c < MAX; c++)
+ for (unsigned long d = 0; d < MAX; d++)
+ for (unsigned long e = 0; e < MAX; e++)
+ for (unsigned long f = 0; f < MAX; f++)
+ for (unsigned long g = 0; g < MAX; g++)
+ *res += a * in;
+}
+