[Bug tree-optimization/81292] [8 regression] ICE in zero_length_string, at tree-ssa-strlen.c:822
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81292 --- Comment #10 from Dmitry G. Dyachenko --- r249961 PASS for me
[Bug tree-optimization/81292] [8 regression] ICE in zero_length_string, at tree-ssa-strlen.c:822
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81292 --- Comment #10 from Dmitry G. Dyachenko --- r249961 PASS for me
[Bug tree-optimization/81292] [8 regression] ICE in zero_length_string, at tree-ssa-strlen.c:822
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81292 --- Comment #10 from Dmitry G. Dyachenko --- r249961 PASS for me
[Bug tree-optimization/81292] [8 regression] ICE in zero_length_string, at tree-ssa-strlen.c:822
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81292 rsandifo at gcc dot gnu.org changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #9 from rsandifo at gcc dot gnu.org --- Fixed.
[Bug tree-optimization/81292] [8 regression] ICE in zero_length_string, at tree-ssa-strlen.c:822
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81292 --- Comment #8 from rsandifo at gcc dot gnu.org --- Author: rsandifo Date: Tue Jul 4 11:48:44 2017 New Revision: 249961 URL: https://gcc.gnu.org/viewcvs?rev=249961=gcc=rev Log: PR 81292: ICE on related strlens after r249880 r249880 installed the result of a strlen in a strinfo if the strinfo wasn't previously a full string. But as Jakub says in the PR comments, we can't just do that in isolation, because there are no vdefs on the call that would invalidate any related strinfos. This patch updates the related strinfos if the adjustment is simple and invalidates them otherwise. As elsewhere, we treat adjustments of the form strlen +/- INTEGER_CST as simple but anything else as too complex. 2017-07-04 Richard Sandifordgcc/ PR tree-optimization/81292 * tree-ssa-strlen.c (handle_builtin_strlen): When setting full_string_p, also call adjust_related_strinfos if the adjustment is simple, otherwise invalidate related strinfos. gcc/testsuite/ PR tree-optimization/81292 * gcc.dg/pr81292-1.c: New test. * gcc.dg/pr81292-2.c: Likewise. Added: trunk/gcc/testsuite/gcc.dg/pr81292-1.c trunk/gcc/testsuite/gcc.dg/pr81292-2.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-strlen.c
[Bug tree-optimization/81292] [8 regression] ICE in zero_length_string, at tree-ssa-strlen.c:822
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81292 --- Comment #7 from Jakub Jelinek --- Comment on attachment 41671 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41671 Proposed patch LGTM
[Bug tree-optimization/81292] [8 regression] ICE in zero_length_string, at tree-ssa-strlen.c:822
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81292 --- Comment #6 from rsandifo at gcc dot gnu.org --- Created attachment 41671 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41671=edit Proposed patch This is the patch I'm testing.
[Bug tree-optimization/81292] [8 regression] ICE in zero_length_string, at tree-ssa-strlen.c:822
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81292 rsandifo at gcc dot gnu.org changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rsandifo at gcc dot gnu.org --- Comment #5 from rsandifo at gcc dot gnu.org --- (In reply to Jakub Jelinek from comment #4) > The problem is that we hit: > if (si != NULL) > { > if (!si->full_string_p && !si->stmt) > { > /* Until now we only had a lower bound on the string length. > Install LHS as the actual length. */ > si = unshare_strinfo (si); > si->nonzero_chars = lhs; > si->full_string_p = true; > } > return; > } > in handle_builtin_strlen, which changes just that single strinfo record, but > doesn't do anything for the related ones. And as strlen doesn't have a vdef > (it is a pure function), nothing is invalidated, so we end up with a mixture > of related strinfos where some strinfos are full_string_p and others are > not, Bah, sorry, I hadn't considered the lack of a vdef here. > and e.g. zero_length_string has asserts that this does not happen. > So, either handle_builtin_strlen needs to adjust also the related strinfos > if any (note, maybe even if verify_related_strinfos fails we might need to > do that or invalidate them manually), or we need to invalidate them, or not > to record this change if we can't adjust or invalidate them all. Ack. Will fix.
[Bug tree-optimization/81292] [8 regression] ICE in zero_length_string, at tree-ssa-strlen.c:822
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81292 Jakub Jelinek changed: What|Removed |Added CC||rsandifo at gcc dot gnu.org --- Comment #4 from Jakub Jelinek --- The problem is that we hit: if (si != NULL) { if (!si->full_string_p && !si->stmt) { /* Until now we only had a lower bound on the string length. Install LHS as the actual length. */ si = unshare_strinfo (si); si->nonzero_chars = lhs; si->full_string_p = true; } return; } in handle_builtin_strlen, which changes just that single strinfo record, but doesn't do anything for the related ones. And as strlen doesn't have a vdef (it is a pure function), nothing is invalidated, so we end up with a mixture of related strinfos where some strinfos are full_string_p and others are not, and e.g. zero_length_string has asserts that this does not happen. So, either handle_builtin_strlen needs to adjust also the related strinfos if any (note, maybe even if verify_related_strinfos fails we might need to do that or invalidate them manually), or we need to invalidate them, or not to record this change if we can't adjust or invalidate them all.
[Bug tree-optimization/81292] [8 regression] ICE in zero_length_string, at tree-ssa-strlen.c:822
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81292 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- Better testcase, the above has UB: void foo (char *x) { x[__builtin_strlen (x)] = ' '; x[__builtin_strlen (x)] = ' '; }
[Bug tree-optimization/81292] [8 regression] ICE in zero_length_string, at tree-ssa-strlen.c:822
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81292 Richard Biener changed: What|Removed |Added Target Milestone|--- |8.0
[Bug tree-optimization/81292] [8 regression] ICE in zero_length_string, at tree-ssa-strlen.c:822
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81292 --- Comment #2 from Marek Polacek --- Likely r249880.
[Bug tree-optimization/81292] [8 regression] ICE in zero_length_string, at tree-ssa-strlen.c:822
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81292 Marek Polacek changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2017-07-03 CC||mpolacek at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Marek Polacek --- Confirmed.