Bug 93203 - [10 Regression] ICE in decide_about_value, at ipa-cp.c:5448 since r278893
Summary: [10 Regression] ICE in decide_about_value, at ipa-cp.c:5448 since r278893
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ipa (show other bugs)
Version: 10.0
: P1 normal
Target Milestone: 10.0
Assignee: fxue
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2020-01-08 18:19 UTC by Martin Liška
Modified: 2020-02-18 13:51 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 9.2.0
Known to fail: 10.0
Last reconfirmed: 2020-01-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2020-01-08 18:19:00 UTC
I see ICE for the following test-case:

$ cat ipacp.ii
class a {
public:
  a(char *);
};
class ad {
public:
  ad(a *);
};
class b {};
using ah = class ak {
  using al = char;

public:
  ak(b) : ak(0) {}
  ak an() { return ap & 1; }
  al ap;
  ak(al af) : ap(af) {}
};
struct at {
  ah au;
  int av;
  char aw;
  char ax;
};
class az {
public:
  struct ba {
    void bb(ak am) {
      ak bc = am.an();
      bb(bc);
    }
  };
  void bd(ak am) { be.bb(am); }
  ba be;
};
class bg {
public:
  int bh;
  at bi;
};
int bj;
int *bk;
int c;
class bl {
  bool bm();
  bg bn;
  az bo;
  int e;
  int bq;
};
class bs {
public:
  bs(int *, ah *, char *, char *, int);
};
template < typename bt > class bu : bs {
  using bv = typename bt::bv;

public:
  template < typename... bx >
  bu(a *by, int *bz, at body, bx...)
      : bs(bz, &body.au, &body.aw, &body.ax, body.av), ca(bx()...), cb(by),
        cc(by), cd(by), ce(by) {}
  void cf() {
    auto cg = ch();
    auto ci = *cj();
    ca.ck(this, cg, &ci);
  }
  bt ca;
  ad cb;
  ad cc;
  ad cd;
  ad ce;
  bv *cj();
  bv ch();
};
class cl {
public:
  using bv = struct {};
  cl(az *, int, int, int, int, a *, int, int **);
  void ck(bs *, bv, bv *) {
    b d;
    ak ci(d);
    bo.bd(ci);
  }
  az bo;
};
bool bl::bm() {
  a by("");
  bu< cl > cn(&by, &bj, bn.bi, &bo, c, bn.bh, e, 0, &by, bq, &bk);
  cn.cf();
}

$ g++ -O3 ipacp.ii -m32
ipacp.ii: In member function ‘bool bl::bm()’:
ipacp.ii:88:8: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
   88 |   a by("");
      |        ^~
ipacp.ii:91:1: warning: no return statement in function returning non-void [-Wreturn-type]
   91 | }
      | ^
during IPA pass: cp
ipacp.ii: At global scope:
ipacp.ii:91:1: internal compiler error: in decide_about_value, at ipa-cp.c:5448
0x609057 decide_about_value<tree_node*>
	/home/marxin/Programming/gcc2/gcc/ipa-cp.c:5448
0x141fe42 decide_whether_version_node
	/home/marxin/Programming/gcc2/gcc/ipa-cp.c:5507
0x1421f17 ipcp_decision_stage
	/home/marxin/Programming/gcc2/gcc/ipa-cp.c:5653
0x1421f17 ipcp_driver
	/home/marxin/Programming/gcc2/gcc/ipa-cp.c:5836
0x1421f17 execute
	/home/marxin/Programming/gcc2/gcc/ipa-cp.c:5927
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 1 GCC Commits 2020-02-10 04:33:03 UTC
The master branch has been updated by Feng Xue <fxue@gcc.gnu.org>:

https://gcc.gnu.org/g:a0f6a8cb414b687f22c9011a894d5e8e398c4be0

commit r10-6540-ga0f6a8cb414b687f22c9011a894d5e8e398c4be0
Author: Feng Xue <fxue@os.amperecomputing.com>
Date:   Tue Jan 21 20:53:38 2020 +0800

    Generalized value pass-through for self-recusive function (PR ipa/93203)
    
    Besides simple pass-through (aggregate) jump function, arithmetic (aggregate)
    jump function could also bring same (aggregate) value as parameter passed-in
    for self-feeding recursive call.  For example,
    
          f1 (int i)    /*  normal jump function */
             {
                f1 (i & 1);
             }
    
    Suppose i is 0, recursive propagation via (i & 1) also gets 0, which
    can be seen as a simple pass-through of i.
    
          f2 (int *p)  /* aggregate jump function */
             {
                int t = *p & 1;
                f2 (&t);
             }
    Likewise, if *p is 0, (*p & 1) is also 0, and &t is an aggregate simple
    pass-through of p.
    
    2020-02-10  Feng Xue  <fxue@os.amperecomputing.com>
    
            PR ipa/93203
            * ipa-cp.c (ipcp_lattice::add_value): Add source with same call edge
            but different source value.
            (adjust_callers_for_value_intersection): New function.
            (gather_edges_for_value): Adjust order of callers to let a
            non-self-recursive caller be the first element.
            (self_recursive_pass_through_p): Add a new parameter "simple", and
            check generalized self-recursive pass-through jump function.
            (self_recursive_agg_pass_through_p): Likewise.
            (find_more_scalar_values_for_callers_subset): Compute value from
            pass-through jump function for self-recursive.
            (intersect_with_plats): Cleanup previous implementation code for value
            itersection with self-recursive call edge.
            (intersect_with_agg_replacements): Likewise.
            (intersect_aggregates_with_edge): Deduce value from pass-through jump
            function for self-recursive call edge.  Cleanup previous implementation
            code for value intersection with self-recursive call edge.
            (decide_whether_version_node): Remove dead callers and adjust order
            to let a non-self-recursive caller be the first element.
    
            PR ipa/93203
            * g++.dg/ipa/pr93203.C: New test.
Comment 2 GCC Commits 2020-02-10 04:52:41 UTC
The master branch has been updated by Feng Xue <fxue@gcc.gnu.org>:

https://gcc.gnu.org/g:a5f79f225e637d59a7b6e26ae62b74b0019d2e85

commit r10-6541-ga5f79f225e637d59a7b6e26ae62b74b0019d2e85
Author: Feng Xue <fxue@os.amperecomputing.com>
Date:   Mon Feb 10 12:46:45 2020 +0800

    Update testcase ChangeLog for PR93203
    
    2020-02-10  Feng Xue  <fxue@os.amperecomputing.com>
    
            PR ipa/93203
            * g++.dg/ipa/pr93203.C: New test.
            * gcc.dg/ipa/ipcp-1.c: Change dump string.
Comment 3 David Binderman 2020-02-10 17:18:36 UTC
I tried the source code file pr93203.C on ARM raspberry pi hardware
with compiler flag -O3 and it crashed a little later at line 5467.

Maybe the patch isn't quite right at optimisation level -O3 ?
Comment 4 David Binderman 2020-02-10 19:59:13 UTC
Another false result produced by my bad gcc config.
Please ignore my previous comment.
Comment 5 Martin Jambor 2020-02-18 13:51:24 UTC
This has been fixed with the aforementioned patches.