public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Sebor <msebor@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5863] Pass GIMPLE statement to compute_objsize. Date: Thu, 9 Dec 2021 16:52:10 +0000 (GMT) [thread overview] Message-ID: <20211209165210.733D23858016@sourceware.org> (raw) https://gcc.gnu.org/g:9354a7d70caef1c94b8d0a66bb2fd4d86c037e7d commit r12-5863-g9354a7d70caef1c94b8d0a66bb2fd4d86c037e7d Author: Martin Sebor <msebor@redhat.com> Date: Sat Dec 4 16:57:48 2021 -0700 Pass GIMPLE statement to compute_objsize. gcc/ChangeLog: * gimple-ssa-warn-restrict.c (builtin_access::builtin_access): Pass GIMPLE statement to compute_objsize. * pointer-query.cc (compute_objsize): Add a statement argument. * pointer-query.h (compute_objsize): Define a new overload. Diff: --- gcc/gimple-ssa-warn-restrict.c | 4 ++-- gcc/pointer-query.cc | 10 +++++----- gcc/pointer-query.h | 9 +++++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c index d1df9ca8d4f..ca2d4c2c32e 100644 --- a/gcc/gimple-ssa-warn-restrict.c +++ b/gcc/gimple-ssa-warn-restrict.c @@ -777,7 +777,7 @@ builtin_access::builtin_access (range_query *query, gimple *call, if (!POINTER_TYPE_P (TREE_TYPE (addr))) addr = build1 (ADDR_EXPR, (TREE_TYPE (addr)), addr); - if (tree dstsize = compute_objsize (addr, ostype)) + if (tree dstsize = compute_objsize (addr, call, ostype)) dst.basesize = wi::to_offset (dstsize); else if (POINTER_TYPE_P (TREE_TYPE (addr))) dst.basesize = HOST_WIDE_INT_MIN; @@ -791,7 +791,7 @@ builtin_access::builtin_access (range_query *query, gimple *call, if (!POINTER_TYPE_P (TREE_TYPE (addr))) addr = build1 (ADDR_EXPR, (TREE_TYPE (addr)), addr); - if (tree srcsize = compute_objsize (addr, ostype)) + if (tree srcsize = compute_objsize (addr, call, ostype)) src.basesize = wi::to_offset (srcsize); else if (POINTER_TYPE_P (TREE_TYPE (addr))) src.basesize = HOST_WIDE_INT_MIN; diff --git a/gcc/pointer-query.cc b/gcc/pointer-query.cc index a8c9671e3ba..c75c4da6b60 100644 --- a/gcc/pointer-query.cc +++ b/gcc/pointer-query.cc @@ -1645,7 +1645,7 @@ handle_array_ref (tree aref, gimple *stmt, bool addr, int ostype, offset_int orng[2]; tree off = pref->eval (TREE_OPERAND (aref, 1)); range_query *const rvals = qry ? qry->rvals : NULL; - if (!get_offset_range (off, NULL, orng, rvals)) + if (!get_offset_range (off, stmt, orng, rvals)) { /* Set ORNG to the maximum offset representable in ptrdiff_t. */ orng[1] = wi::to_offset (TYPE_MAX_VALUE (ptrdiff_type_node)); @@ -1732,7 +1732,7 @@ handle_mem_ref (tree mref, gimple *stmt, int ostype, access_ref *pref, offset_int orng[2]; tree off = pref->eval (TREE_OPERAND (mref, 1)); range_query *const rvals = qry ? qry->rvals : NULL; - if (!get_offset_range (off, NULL, orng, rvals)) + if (!get_offset_range (off, stmt, orng, rvals)) { /* Set ORNG to the maximum offset representable in ptrdiff_t. */ orng[1] = wi::to_offset (TYPE_MAX_VALUE (ptrdiff_type_node)); @@ -1948,7 +1948,7 @@ compute_objsize_r (tree ptr, gimple *stmt, int ostype, access_ref *pref, offset_int orng[2]; tree off = pref->eval (TREE_OPERAND (ptr, 1)); - if (get_offset_range (off, NULL, orng, rvals)) + if (get_offset_range (off, stmt, orng, rvals)) pref->add_offset (orng[0], orng[1]); else pref->add_max_offset (); @@ -2197,13 +2197,13 @@ compute_objsize (tree ptr, gimple *stmt, int ostype, access_ref *pref, once callers transition to one of the two above. */ tree -compute_objsize (tree ptr, int ostype, tree *pdecl /* = NULL */, +compute_objsize (tree ptr, gimple *stmt, int ostype, tree *pdecl /* = NULL */, tree *poff /* = NULL */, range_query *rvals /* = NULL */) { /* Set the initial offsets to zero and size to negative to indicate none has been computed yet. */ access_ref ref; - tree size = compute_objsize (ptr, nullptr, ostype, &ref, rvals); + tree size = compute_objsize (ptr, stmt, ostype, &ref, rvals); if (!size || !ref.base0) return NULL_TREE; diff --git a/gcc/pointer-query.h b/gcc/pointer-query.h index 82cb81b3987..cbc87c86ed3 100644 --- a/gcc/pointer-query.h +++ b/gcc/pointer-query.h @@ -260,8 +260,13 @@ inline tree compute_objsize (tree ptr, int ostype, access_ref *pref) } /* Legacy/transitional API. Should not be used in new code. */ -extern tree compute_objsize (tree, int, tree * = nullptr, tree * = nullptr, - range_query * = nullptr); +extern tree compute_objsize (tree, gimple *, int, tree * = nullptr, + tree * = nullptr, range_query * = nullptr); +inline tree compute_objsize (tree ptr, int ostype, tree *pdecl = nullptr, + tree *poff = nullptr, range_query *rvals = nullptr) +{ + return compute_objsize (ptr, nullptr, ostype, pdecl, poff, rvals); +} /* Return the field at the constant offset. */ extern tree field_at_offset (tree, tree, HOST_WIDE_INT,
reply other threads:[~2021-12-09 16:52 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20211209165210.733D23858016@sourceware.org \ --to=msebor@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).