From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 88022 invoked by alias); 10 Dec 2018 10:27:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 88009 invoked by uid 89); 10 Dec 2018 10:27:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Envelope-From:sk:richard, ipacp, 88214, IPA-CP X-HELO: mail-lf1-f66.google.com Received: from mail-lf1-f66.google.com (HELO mail-lf1-f66.google.com) (209.85.167.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Dec 2018 10:27:19 +0000 Received: by mail-lf1-f66.google.com with SMTP id u18so7554752lff.10 for ; Mon, 10 Dec 2018 02:27:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bWv1RY2OQh3RWbaH0xsEl+UJuJwETfCSa4ztcZKOGBE=; b=qDiVcYPRc5LYbyjgsiE9dhrx2T+xgVOklRjOLo1PXAx/cre+AEvfupw/vpHL3bT0wZ gWukSfEkIMAmleFvC1k0qoFjlSHEG8qj6bnqLe5h58TWDaP+0Jjx88viPz+JEL37e+0Q 0ytM9dpbmAkgLnjoINPNRQkY20IhVrZ44g9DIVYOAytGBnM08U8nbk8CNNS2Lc5a4FUh pF1tVf6TvoLy375CXrXCfslvhi6Bx1nDi/pr2v2QbnXh3OCJhSEc+FO83X7Sr4+bf8xM bOeJfH1Z/OSchmtiuNQojEVY6sneKRW+x3ymH//SJ+DzTuTST7X7ryXx+UgofYXtePfq QEDg== MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Mon, 10 Dec 2018 10:27:00 -0000 Message-ID: Subject: Re: [PR 88214] Check that an argument is pointer before attempting agg jf construction from it To: Martin Jambor Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg00561.txt.bz2 On Fri, Dec 7, 2018 at 3:59 PM Martin Jambor wrote: > > Hi, > > ICE in PR 88214 happens because a type-mismatch in K&R C code makes > IPA-CP analysis call ao_ref_init_from_ptr_and_size on an integer > SSA_NAME, this function in turn constructs a temporary MEM_REF based on > that integer SSA_NAME and then later on call_may_clobber_ref_p_1 treats > the MEM_REF base as a pointer, gets its SSA_NAME_PTR_INFO and tries to > work with bitmaps there. But because the SSA_NAME is an integer, there > is no SSA_NAME_PTR_INFO, there is range info instead and this leads to a > crash. > > On a related note, would people object to adding the following assert, > which would have made this bug much more straightforward to find? That's fine with me. > index 85a5de7..66cf2f2 100644 > --- a/gcc/tree-ssa-alias.c > +++ b/gcc/tree-ssa-alias.c > @@ -710,6 +710,7 @@ ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size) > } > else > { > + gcc_assert (POINTER_TYPE_P (TREE_TYPE (ptr))); > ref->base = build2 (MEM_REF, char_type_node, > ptr, null_pointer_node); > ref->offset = 0; > > > The bug itself can be fixed with the patch below. I have verified it > avoids the ICE on powerpc64-linux and did a full bootstrap and test on > an x86_64-linux. The patch is simple enough that I believe that is good > enough. OK. Richard. > > 2018-12-06 Martin Jambor > > PR ipa/88214 > * ipa-prop.c (determine_locally_known_aggregate_parts): Make sure > we check pointers against pointers. > > testsuite/ > * gcc.dg/ipa/pr88214.c: New test. > --- > gcc/ipa-prop.c | 3 ++- > gcc/testsuite/gcc.dg/ipa/pr88214.c | 10 ++++++++++ > 2 files changed, 12 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.dg/ipa/pr88214.c > > diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c > index 74052350ac1..4dbe26829e3 100644 > --- a/gcc/ipa-prop.c > +++ b/gcc/ipa-prop.c > @@ -1569,7 +1569,8 @@ determine_locally_known_aggregate_parts (gcall *call, tree arg, > if (TREE_CODE (arg) == SSA_NAME) > { > tree type_size; > - if (!tree_fits_uhwi_p (TYPE_SIZE (TREE_TYPE (arg_type)))) > + if (!tree_fits_uhwi_p (TYPE_SIZE (TREE_TYPE (arg_type))) > + || !POINTER_TYPE_P (TREE_TYPE (arg))) > return; > check_ref = true; > arg_base = arg; > diff --git a/gcc/testsuite/gcc.dg/ipa/pr88214.c b/gcc/testsuite/gcc.dg/ipa/pr88214.c > new file mode 100644 > index 00000000000..4daa9829e75 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/ipa/pr88214.c > @@ -0,0 +1,10 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > + > +void i(); > + short a; > + void b(e) char * e; > + { > + i(); > + b(a); > + } > -- > 2.19.1 > > >