public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amacleod at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/105329] Bogus restrict warning when assigning 1-char string literal to std::string
Date: Thu, 21 Apr 2022 22:51:08 +0000	[thread overview]
Message-ID: <bug-105329-4-0TCobo6KeH@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105329-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105329

--- Comment #3 from Andrew Macleod <amacleod at redhat dot com> ---
Just to bookmark where the analysis is since im out for a few days, in the
restrict pass, with ranger tracing on, the code sequence is:


  <bb 15> [local count: 14831835]:
  __nleft_49 = (const size_type) _48;
  __builtin_memcpy (_22, "5", __nleft_49);

and the ranger trace from wrestrict shows:
             TRUE : (5628) range_of_expr (_48) long int [-INF, 0][2, +INF]
           TRUE : (5617) range_of_stmt (__nleft_49) const size_type [2,
9223372036854775807]

So we know _48 is non-zero, and when I further delve into things, ranger is
calculating __nleft_49 correct as  [0, 0][2, +INF], but when it merges this
with the current known global range, THAT has been set somewhere as [2,
9223372036854775807] 

Im trying to find where the global value is first set. when I put a breakpoint
in the set and get routines, the very first thing that triggers is:

#0  gimple_range_global (name=0x7fffefd0be10) at
/opt/notnfs/amacleod/master/gcc/gcc/value-query.cc:419
#1  0x0000000002e73534 in ranger_cache::get_global_range (this=0x41797b8,
r=..., name=0x7fffefd0be10) at
/opt/notnfs/amacleod/master/gcc/gcc/gimple-range-cache.cc:925
#2  0x0000000002e73580 in ranger_cache::get_global_range (this=0x41797b8,
r=..., name=0x7fffefd0be10, current_p=@0x7fffffff9c37: false) at
/opt/notnfs/amacleod/master/gcc/gcc/gimple-range-cache.cc:939
#3  0x0000000002e6f731 in gimple_ranger::range_of_stmt (this=0x4179790, r=...,
s=0x7fffef265000, name=0x7fffefd0be10) at
/opt/notnfs/amacleod/master/gcc/gcc/gimple-range.cc:307
#4  0x0000000002e6edc2 in gimple_ranger::range_on_entry (this=0x4179790, r=...,
bb=0x7fffeecc4340, name=0x7fffefd0be10) at
/opt/notnfs/amacleod/master/gcc/gcc/gimple-range.cc:151
#5  0x0000000002e6ec40 in gimple_ranger::range_of_expr (this=0x4179790, r=...,
expr=0x7fffefd0be10, stmt=0x7fffeeca8f78) at
/opt/notnfs/amacleod/master/gcc/gcc/gimple-range.cc:128
#6  0x0000000001b4cd0d in get_range (val=0x7fffefd0be10, stmt=0x7fffeeca8f78,
minmax=0x7fffffffbe10, rvals=0x4179790) at
/opt/notnfs/amacleod/master/gcc/gcc/tree-ssa-strlen.cc:219
#7  0x00000000016f8fae in get_offset_range (x=0x7fffefd0be10,
stmt=0x7fffeeca8f78, r=0x7fffffffc0b0, rvals=0x4179790) at
/opt/notnfs/amacleod/master/gcc/gcc/pointer-query.cc:92
#8  0x0000000001702c2f in handle_ssa_name (ptr=0x7fffef8d20d8, addr=false,
ostype=0, pref=0x7fffffffc5d0, snlim=..., qry=0x4167468) at
/opt/notnfs/amacleod/master/gcc/gcc/pointer-query.cc:2157
#9  0x000000000170375b in compute_objsize_r (ptr=0x7fffef8d20d8,
stmt=0x7fffeeca8f78, addr=false, ostype=0, pref=0x7fffffffc5d0, snlim=...,
qry=0x4167468)
    at /opt/notnfs/amacleod/master/gcc/gcc/pointer-query.cc:2321
#10 0x0000000001703907 in compute_objsize (ptr=0x7fffef8d20d8,
stmt=0x7fffeeca8f78, ostype=0, pref=0x7fffffffc5d0, ptr_qry=0x4167468) at
/opt/notnfs/amacleod/master/gcc/gcc/pointer-query.cc:2355
#11 0x00000000016ff4e4 in pointer_query::get_ref (this=0x4167468,
ptr=0x7fffef8d20d8, stmt=0x7fffeeca8f78, pref=0x7fffffffc5d0, ostype=0) at
/opt/notnfs/amacleod/master/gcc/gcc/pointer-query.cc:1505
#12 0x00000000013b99c3 in (anonymous
namespace)::pass_waccess::check_dangling_stores (this=0x4167410,
bb=0x7fffeecc4340, stores=..., bbs=...)
    at /opt/notnfs/amacleod/master/gcc/gcc/gimple-ssa-warn-access.cc:4528

with
p vr.dump(stderr)
const size_type [1, 9223372036854775807]

I also have a breakpoint in set_range_info for this name which hasn't been
triggered.   So either the set routine have been bypassed or perhaps inlining
is setting this global value?

Im still trying to figure out who and where has decided that __nleft_49 is [2,
0x7FFFFFFFFFFFFFFF] instead of [2, 0xFFFFFFFFFFFFFFFFFFFF]

  parent reply	other threads:[~2022-04-21 22:51 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21  7:41 [Bug c++/105329] New: " boris at kolpackov dot net
2022-04-21 11:15 ` [Bug tree-optimization/105329] " rguenth at gcc dot gnu.org
2022-04-21 20:50 ` amacleod at redhat dot com
2022-04-21 22:51 ` amacleod at redhat dot com [this message]
2022-04-22 10:31 ` aldyh at gcc dot gnu.org
2022-04-25 17:50 ` amacleod at redhat dot com
2022-04-25 22:25 ` mattias.ellert at physics dot uu.se
2022-04-26 15:04 ` [Bug tree-optimization/105329] [12 Regression] Bogus restrict warning when assigning 1-char string literal to std::string since r12-3347-g8af8abfbbace49e6 marxin at gcc dot gnu.org
2022-05-02 12:44 ` [Bug tree-optimization/105329] [12/13 " rguenth at gcc dot gnu.org
2022-05-02 12:45 ` rguenth at gcc dot gnu.org
2022-05-02 12:46 ` rguenth at gcc dot gnu.org
2022-05-02 12:57 ` rguenth at gcc dot gnu.org
2022-05-02 13:22 ` rguenth at gcc dot gnu.org
2022-05-02 13:33 ` jakub at gcc dot gnu.org
2022-05-02 13:58 ` jakub at gcc dot gnu.org
2022-05-02 16:04 ` jakub at gcc dot gnu.org
2022-05-02 19:43 ` jakub at gcc dot gnu.org
2022-05-02 22:08 ` redi at gcc dot gnu.org
2022-05-06  3:59 ` mattias.ellert at physics dot uu.se
2022-05-06  8:33 ` jakub at gcc dot gnu.org
2022-05-20  8:13 ` rguenth at gcc dot gnu.org
2022-07-26 12:05 ` jakub at gcc dot gnu.org
2022-09-12  9:37 ` cvs-commit at gcc dot gnu.org
2022-09-29 15:19 ` msebor at gcc dot gnu.org
2022-09-30 16:55 ` dan at stahlke dot org
2022-09-30 17:16 ` dan at stahlke dot org
2023-02-21 18:30 ` 49tbwddbqeazdawz at chyen dot cc
2023-02-21 19:28 ` redi at gcc dot gnu.org
2023-02-22 17:28 ` 49tbwddbqeazdawz at chyen dot cc
2023-02-22 17:52 ` redi at gcc dot gnu.org
2023-02-24 14:10 ` wielkiegie at gmail dot com
2023-05-08 12:24 ` [Bug tree-optimization/105329] [12/13/14 " rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105329-4-0TCobo6KeH@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).