public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/63989] New: tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length
@ 2014-11-20 9:31 jakub at gcc dot gnu.org
2014-11-20 9:44 ` [Bug tree-optimization/63989] " jakub at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-11-20 9:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63989
Bug ID: 63989
Summary: tree-ssa-strlen.c doesn't handle constant pointer plus
and array refs if constant offset is smaller than
known constant string length
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: jakub at gcc dot gnu.org
CC: dimhen at gmail dot com, jakub at gcc dot gnu.org,
nheghathivhistha at gmail dot com, rguenth at gcc dot gnu.org,
trippels at gcc dot gnu.org
Depends on: 61773
Blocks: 63787
+++ This bug was initially created as a clone of Bug #61773 +++
char *foo (void)
{
char *p = __builtin_malloc (64);
char *q = __builtin_malloc (64);
__builtin_strcat (q, "abcde");
__builtin_strcat (p, "ab");
p[1] = q[3];
__builtin_strcat (p, q);
return q;
}
gives
> ../../obj2/gcc/cc1 -quiet -O2 t.c
t.c: In function ‘foo’:
t.c:1:7: internal compiler error: in get_string_length, at
tree-ssa-strlen.c:417
char *foo (void)
^
0x876c3d2 get_string_length
/space/rguenther/tramp3d/trunk/gcc/tree-ssa-strlen.c:417
0x8772b02 get_string_length
/space/rguenther/tramp3d/trunk/gcc/tree.h:2731
0x8772b02 handle_builtin_strlen
/space/rguenther/tramp3d/trunk/gcc/tree-ssa-strlen.c:899
(gdb) up
#1 0x0876c3d3 in get_string_length (si=0x3c)
at /space/rguenther/tramp3d/trunk/gcc/tree-ssa-strlen.c:417
417 gcc_assert (builtin_decl_implicit_p (BUILT_IN_STPCPY));
while trying to write a testcase that shows that handle_char_store should
handle a character copy from a known non-zero value. Well, while really
trying to incrementally teach handle_char_store to handle arbitrary
stores.
>From gcc-bugs-return-467687-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Nov 20 09:44:40 2014
Return-Path: <gcc-bugs-return-467687-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 14002 invoked by alias); 20 Nov 2014 09:44:39 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 13906 invoked by uid 48); 20 Nov 2014 09:44:34 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/63989] tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length
Date: Thu, 20 Nov 2014 09:44:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: target_milestone
Message-ID: <bug-63989-4-M2yNLIBOjN@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63989-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63989-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-11/txt/msg02159.txt.bz2
Content-length: 289
https://gcc.gnu.org/bugzilla/show_bug.cgi?idc989
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |5.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/63989] tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length
2014-11-20 9:31 [Bug tree-optimization/63989] New: tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length jakub at gcc dot gnu.org
@ 2014-11-20 9:44 ` jakub at gcc dot gnu.org
2014-11-20 11:20 ` rguenther at suse dot de
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-11-20 9:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63989
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-11-20
Ever confirmed|0 |1
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, we are talking here about e.g.
int
f1 (char *p)
{
__builtin_strcpy (p, "foobar");
return __builtin_strlen (p + 2);
}
int
f2 (char *p)
{
__builtin_strcpy (p, "foobar");
p[2] = '\0';
return __builtin_strlen (p);
}
int
f3 (char *p)
{
__builtin_strcpy (p, "foobar");
p[2] = '\0';
return __builtin_strlen (p + 3);
}
int
f4 (char *p)
{
__builtin_strcpy (p, "foobar");
p[2] = 'z';
return __builtin_strlen (p);
}
and then also determining using get_string_length (if constant) whether a
character pointer dereference is known to be zero or known to be non-zero.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/63989] tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length
2014-11-20 9:31 [Bug tree-optimization/63989] New: tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length jakub at gcc dot gnu.org
2014-11-20 9:44 ` [Bug tree-optimization/63989] " jakub at gcc dot gnu.org
@ 2014-11-20 11:20 ` rguenther at suse dot de
2014-11-21 9:38 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenther at suse dot de @ 2014-11-20 11:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63989
--- Comment #2 from rguenther at suse dot de <rguenther at suse dot de> ---
On Thu, 20 Nov 2014, jakub at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63989
>
> Jakub Jelinek <jakub at gcc dot gnu.org> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> Status|UNCONFIRMED |NEW
> Last reconfirmed| |2014-11-20
> Ever confirmed|0 |1
>
> --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> So, we are talking here about e.g.
>
> int
> f1 (char *p)
> {
> __builtin_strcpy (p, "foobar");
> return __builtin_strlen (p + 2);
> }
>
> int
> f2 (char *p)
> {
> __builtin_strcpy (p, "foobar");
> p[2] = '\0';
> return __builtin_strlen (p);
> }
>
> int
> f3 (char *p)
> {
> __builtin_strcpy (p, "foobar");
> p[2] = '\0';
> return __builtin_strlen (p + 3);
> }
>
> int
> f4 (char *p)
> {
> __builtin_strcpy (p, "foobar");
> p[2] = 'z';
> return __builtin_strlen (p);
> }
>
> and then also determining using get_string_length (if constant) whether a
> character pointer dereference is known to be zero or known to be non-zero.
Well, we are mainly talking about the case where I had to XFAIL
gcc.dg/strlenopt-8.c for us now inline-expanding a two-character
memcpy to a short store.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/63989] tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length
2014-11-20 9:31 [Bug tree-optimization/63989] New: tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length jakub at gcc dot gnu.org
2014-11-20 9:44 ` [Bug tree-optimization/63989] " jakub at gcc dot gnu.org
2014-11-20 11:20 ` rguenther at suse dot de
@ 2014-11-21 9:38 ` jakub at gcc dot gnu.org
2014-12-08 17:25 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-11-21 9:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63989
Bug 63989 depends on bug 61773, which changed state.
Bug 61773 Summary: [5 Regression] ICE in tree-ssa-strlen.c:417
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61773
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/63989] tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length
2014-11-20 9:31 [Bug tree-optimization/63989] New: tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length jakub at gcc dot gnu.org
` (2 preceding siblings ...)
2014-11-21 9:38 ` jakub at gcc dot gnu.org
@ 2014-12-08 17:25 ` jakub at gcc dot gnu.org
2015-01-08 21:31 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-08 17:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63989
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 34220
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34220&action=edit
gcc5-pr63989-wip1.patch
So, for start, this untested patch deals with #c1 f1 case. Still need to
extend handle_char_store etc.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/63989] tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length
2014-11-20 9:31 [Bug tree-optimization/63989] New: tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length jakub at gcc dot gnu.org
` (3 preceding siblings ...)
2014-12-08 17:25 ` jakub at gcc dot gnu.org
@ 2015-01-08 21:31 ` jakub at gcc dot gnu.org
2015-04-22 12:01 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-01-08 21:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63989
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Thu Jan 8 21:30:56 2015
New Revision: 219362
URL: https://gcc.gnu.org/viewcvs?rev=219362&root=gcc&view=rev
Log:
PR tree-optimization/63989
* params.def (PARAM_MAX_TRACKED_STRLENS): Increment default
from 1000 to 10000.
* tree-ssa-strlen.c (get_strinfo): Moved earlier.
(get_stridx): If we don't have a record for certain SSA_NAME,
but it is POINTER_PLUS_EXPR of some SSA_NAME we do with
constant offset, call get_stridx_plus_constant.
(get_stridx_plus_constant): New function.
(zero_length_string): Don't use get_stridx here.
* gcc.dg/strlenopt-27.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/strlenopt-27.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/params.def
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa-strlen.c
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/63989] tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length
2014-11-20 9:31 [Bug tree-optimization/63989] New: tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length jakub at gcc dot gnu.org
` (4 preceding siblings ...)
2015-01-08 21:31 ` jakub at gcc dot gnu.org
@ 2015-04-22 12:01 ` jakub at gcc dot gnu.org
2015-07-16 9:18 ` rguenth at gcc dot gnu.org
2022-01-09 0:45 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-04-22 12:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63989
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|5.0 |5.2
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 5.1 has been released.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/63989] tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length
2014-11-20 9:31 [Bug tree-optimization/63989] New: tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length jakub at gcc dot gnu.org
` (5 preceding siblings ...)
2015-04-22 12:01 ` jakub at gcc dot gnu.org
@ 2015-07-16 9:18 ` rguenth at gcc dot gnu.org
2022-01-09 0:45 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-07-16 9:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63989
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|5.2 |5.3
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 5.2 is being released, adjusting target milestone to 5.3.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/63989] tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length
2014-11-20 9:31 [Bug tree-optimization/63989] New: tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length jakub at gcc dot gnu.org
` (6 preceding siblings ...)
2015-07-16 9:18 ` rguenth at gcc dot gnu.org
@ 2022-01-09 0:45 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-09 0:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63989
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|5.5 |---
Keywords| |missed-optimization
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-01-09 0:45 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-20 9:31 [Bug tree-optimization/63989] New: tree-ssa-strlen.c doesn't handle constant pointer plus and array refs if constant offset is smaller than known constant string length jakub at gcc dot gnu.org
2014-11-20 9:44 ` [Bug tree-optimization/63989] " jakub at gcc dot gnu.org
2014-11-20 11:20 ` rguenther at suse dot de
2014-11-21 9:38 ` jakub at gcc dot gnu.org
2014-12-08 17:25 ` jakub at gcc dot gnu.org
2015-01-08 21:31 ` jakub at gcc dot gnu.org
2015-04-22 12:01 ` jakub at gcc dot gnu.org
2015-07-16 9:18 ` rguenth at gcc dot gnu.org
2022-01-09 0:45 ` pinskia at gcc dot gnu.org
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).