public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-2945] ipa/96806 - Fix ICE in ipa-cp due to integer addition overflow
@ 2020-08-31 8:35 Feng Xue
0 siblings, 0 replies; only message in thread
From: Feng Xue @ 2020-08-31 8:35 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:e11c4b7f837bc6b4c22b1f5bf41a9d0608d256be
commit r11-2945-ge11c4b7f837bc6b4c22b1f5bf41a9d0608d256be
Author: Feng Xue <fxue@os.amperecomputing.com>
Date: Mon Aug 31 15:00:52 2020 +0800
ipa/96806 - Fix ICE in ipa-cp due to integer addition overflow
2020-08-31 Feng Xue <fxue@os.amperecomputing.com>
gcc/
PR tree-optimization/96806
* ipa-cp.c (decide_about_value): Use safe_add to avoid cost addition
overflow.
gcc/testsuite/
PR tree-optimization/96806
* g++.dg/ipa/pr96806.C: New test.
Diff:
---
gcc/ipa-cp.c | 8 +++---
gcc/testsuite/g++.dg/ipa/pr96806.C | 53 ++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 4 deletions(-)
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 7ae6c883a1d..b3e7d41ea10 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -5481,11 +5481,11 @@ decide_about_value (struct cgraph_node *node, int index, HOST_WIDE_INT offset,
freq_sum, count_sum,
val->local_size_cost)
&& !good_cloning_opportunity_p (node,
- val->local_time_benefit
- + val->prop_time_benefit,
+ safe_add (val->local_time_benefit,
+ val->prop_time_benefit),
freq_sum, count_sum,
- val->local_size_cost
- + val->prop_size_cost))
+ safe_add (val->local_size_cost,
+ val->prop_size_cost)))
return false;
if (dump_file)
diff --git a/gcc/testsuite/g++.dg/ipa/pr96806.C b/gcc/testsuite/g++.dg/ipa/pr96806.C
new file mode 100644
index 00000000000..28fdf7787a1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr96806.C
@@ -0,0 +1,53 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c++11 -O -fipa-cp -fipa-cp-clone --param=ipa-cp-max-recursive-depth=94 --param=logical-op-non-short-circuit=0" } */
+
+enum a {};
+struct m;
+struct n {
+ a d;
+};
+int o(int, int);
+struct p {
+ char d;
+ char aa;
+ p *ab;
+ bool q() const {
+ int h = d & 4;
+ return h;
+ }
+ char r() const { return aa; }
+ int s(const m *, bool) const;
+} l;
+struct t {
+ p *ac;
+ p *u() { return ac; }
+ p *v(int);
+};
+int w(const p *, const p *, const m *, int = 0);
+struct m : n {
+ struct {
+ t *ad;
+ } ae;
+ char x() const;
+ p *y(int z) const { return ae.ad ? nullptr : ae.ad->v(z); }
+} j;
+int w(const p *z, const p *af, const m *ag, int ah) {
+ int a, g = z->s(ag, true), i = af->s(ag, true);
+ if (af->q()) {
+ if (ag->x())
+ return 0;
+ ah++;
+ char b = af->r();
+ p *c = ag->y(b), *e = ag->ae.ad->u();
+ int d = w(z, c, ag, ah), f = w(z, af ? e : af->ab, ag, ah);
+ a = f ? d : f;
+ return a;
+ }
+ if (g || i == 1)
+ return ag->d ? o(g, i) : o(g, i);
+ return 0;
+}
+void ai() {
+ for (p k;;)
+ w(&k, &l, &j);
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-31 8:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31 8:35 [gcc r11-2945] ipa/96806 - Fix ICE in ipa-cp due to integer addition overflow Feng Xue
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).