public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7531] tree-optimization/104825 - guard modref query Date: Tue, 8 Mar 2022 08:56:08 +0000 (GMT) [thread overview] Message-ID: <20220308085608.57A5A3857029@sourceware.org> (raw) https://gcc.gnu.org/g:dc46350d44c2949ec38deb028960f8040f8e8e5d commit r12-7531-gdc46350d44c2949ec38deb028960f8040f8e8e5d Author: Richard Biener <rguenther@suse.de> Date: Tue Mar 8 08:42:58 2022 +0100 tree-optimization/104825 - guard modref query The following makes sure to guard the modref query in VN on a pointer typed argument. 2022-03-08 Richard Biener <rguenther@suse.de> PR tree-optimization/104825 * tree-ssa-sccvn.cc (visit_reference_op_call): Properly guard modref get_ao_ref on a pointer typed argument. * gcc.dg/torture/pr104825.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/torture/pr104825.c | 14 ++++++++++++++ gcc/tree-ssa-sccvn.cc | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/torture/pr104825.c b/gcc/testsuite/gcc.dg/torture/pr104825.c new file mode 100644 index 00000000000..7affacc2094 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr104825.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Wno-stringop-overread" } */ + +int foo (fmt) +char* fmt; +{ + return (__builtin_strchr (fmt, '*') != 0 + || __builtin_strchr (fmt, 'n') != 0); +} +void bar () +{ + if (foo (1)) + __builtin_abort (); +} diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index d4d0aba880c..66b4fc21f5b 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -5140,11 +5140,12 @@ visit_reference_op_call (tree lhs, gcall *stmt) { accesses.quick_grow (accesses.length () + 1); ao_ref *r = &accesses.last (); - if (!access_node.get_ao_ref (stmt, r)) + tree arg = access_node.get_call_arg (stmt); + if (!POINTER_TYPE_P (TREE_TYPE (arg)) + || !access_node.get_ao_ref (stmt, r)) { /* Initialize a ref based on the argument and unknown offset if possible. */ - tree arg = access_node.get_call_arg (stmt); if (arg && TREE_CODE (arg) == SSA_NAME) arg = SSA_VAL (arg); if (arg
reply other threads:[~2022-03-08 8:56 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=20220308085608.57A5A3857029@sourceware.org \ --to=rguenth@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).