From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 117971 invoked by alias); 23 Mar 2015 19:55:04 -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 117961 invoked by uid 89); 23 Mar 2015 19:55:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 23 Mar 2015 19:55:03 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id D90C58F02C; Mon, 23 Mar 2015 19:55:01 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-58.ams2.redhat.com [10.36.116.58]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2NJswmw018633 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Mon, 23 Mar 2015 15:55:01 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.9/8.14.9) with ESMTP id t2NJsuvJ021457; Mon, 23 Mar 2015 20:54:56 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.9/8.14.9/Submit) id t2NJsssA021456; Mon, 23 Mar 2015 20:54:54 +0100 Date: Mon, 23 Mar 2015 19:55:00 -0000 From: Jakub Jelinek To: Richard Biener , Ilya Enkovich Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix a -fcheck-pointer-bounds -mmpx ICE (PR target/65523) Message-ID: <20150323195454.GA1746@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg01214.txt.bz2 Hi! On the following testcase we ICE, because we don't verify we have the ERF_RETURNS_ARG argument, on non-verified builtins that is possible. Other uses of ERF_RETURNS_ARG seem to verify it. Also, there was an unneeded extra gimple_call_return_flags call, the condition has already checked that ERF_RETURNS_ARG flag is set. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2015-03-23 Jakub Jelinek PR target/65523 * tree-chkp.c (chkp_build_returned_bound): Ignore ERF_RETURNS_ARG calls if they have fewer than needed arguments. * gcc.target/i386/pr65523.c: New test. --- gcc/tree-chkp.c.jj 2015-03-09 08:05:05.000000000 +0100 +++ gcc/tree-chkp.c 2015-03-23 14:37:52.469289930 +0100 @@ -2153,6 +2153,7 @@ chkp_build_returned_bound (gcall *call) tree bounds; gimple stmt; tree fndecl = gimple_call_fndecl (call); + unsigned int retflags; /* To avoid fixing alloca expands in targets we handle it separately. */ @@ -2196,12 +2197,11 @@ chkp_build_returned_bound (gcall *call) } /* Do not use retbnd when returned bounds are equal to some of passed bounds. */ - else if (gimple_call_return_flags (call) & ERF_RETURNS_ARG) + else if (((retflags = gimple_call_return_flags (call)) & ERF_RETURNS_ARG) + && (retflags & ERF_RETURN_ARG_MASK) < gimple_call_num_args (call)) { gimple_stmt_iterator iter = gsi_for_stmt (call); - unsigned int retarg = 0, argno; - if (gimple_call_return_flags (call) & ERF_RETURNS_ARG) - retarg = gimple_call_return_flags (call) & ERF_RETURN_ARG_MASK; + unsigned int retarg = retflags & ERF_RETURN_ARG_MASK, argno; if (gimple_call_with_bounds_p (call)) { for (argno = 0; argno < gimple_call_num_args (call); argno++) --- gcc/testsuite/gcc.target/i386/pr65523.c.jj 2015-03-23 14:44:36.977729292 +0100 +++ gcc/testsuite/gcc.target/i386/pr65523.c 2015-03-23 14:45:17.518071777 +0100 @@ -0,0 +1,11 @@ +/* PR target/65523 */ +/* { dg-do compile } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + +void *memmove (); + +void * +bar () +{ + return memmove (); +} Jakub