From patchwork Thu Nov 7 11:50:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 289305 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C600E2C00A0 for ; Thu, 7 Nov 2013 22:51:25 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=si9xZTEmpstGswslJ k9uXvVEvoUlhqTNjw7RNy2Na0SIWsA5fSYltxAEfIjj38jcPCK7GzWE4DM2136Em usQStZnBOjVxd4XsTH5j/TyxNmf768hrKAKWyGXjdhyNq32nZnWLGPogPrP0FAjK pxyjr83oGiS11YCFtPOd8Hnrmg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=epieY/r/PMnXMjy/vDxZ7VG qhDw=; b=hNXu5Q9/FJ8w2vTh/TJOu+DcPjaALHSwKtPbjIktSX0sA4E9oMw0oxG 2wN1ivxpDIeFmyV5cB5UsDlRR8B1S/OmzCqI+DRrYmKSQAeuuIuQkuD2VS2z6++3 NSUPq7fixIF/Ovi225h5Rju+l5c2JNofL2Vncq4ARaZDYDNdxEUY= Received: (qmail 27530 invoked by alias); 7 Nov 2013 11:51:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 27521 invoked by uid 89); 7 Nov 2013 11:51:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.1 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RDNS_NONE, SPAM_SUBJECT, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pd0-f171.google.com Received: from Unknown (HELO mail-pd0-f171.google.com) (209.85.192.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 07 Nov 2013 11:51:09 +0000 Received: by mail-pd0-f171.google.com with SMTP id w10so487418pde.16 for ; Thu, 07 Nov 2013 03:51:01 -0800 (PST) X-Received: by 10.66.184.168 with SMTP id ev8mr9368500pac.152.1383825061810; Thu, 07 Nov 2013 03:51:01 -0800 (PST) Received: from msticlxl57.ims.intel.com (fmdmzpr04-ext.fm.intel.com. [192.55.55.39]) by mx.google.com with ESMTPSA id ry4sm5821980pab.4.2013.11.07.03.51.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 07 Nov 2013 03:51:01 -0800 (PST) Date: Thu, 7 Nov 2013 15:50:19 +0400 From: Ilya Enkovich To: Richard Biener Cc: GCC Patches Subject: Re: [PATCH, MPX, 2/X] Pointers Checker [10/25] Calls copy and verification Message-ID: <20131107115019.GJ54327@msticlxl57.ims.intel.com> References: <20131031092436.GF54327@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi, Here is an updated patch version. Thanks, Ilya diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 52d9ab0..9d7ae85 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -3030,40 +3030,54 @@ gimple_check_call_args (gimple stmt, tree fndecl, bool args_count_match) { for (i = 0, p = DECL_ARGUMENTS (fndecl); i < nargs; - i++, p = DECL_CHAIN (p)) + i++) { - tree arg; + tree arg = gimple_call_arg (stmt, i); + + /* Skip bound args inserted by Pointer Bounds Checker. */ + if (POINTER_BOUNDS_P (arg)) + continue; + /* We cannot distinguish a varargs function from the case of excess parameters, still deferring the inlining decision to the callee is possible. */ if (!p) break; - arg = gimple_call_arg (stmt, i); + if (p == error_mark_node || arg == error_mark_node || (!types_compatible_p (DECL_ARG_TYPE (p), TREE_TYPE (arg)) && !fold_convertible_p (DECL_ARG_TYPE (p), arg))) return false; + + p = DECL_CHAIN (p); } if (args_count_match && p) return false; } else if (parms) { - for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p)) + for (i = 0, p = parms; i < nargs; i++) { - tree arg; + tree arg = gimple_call_arg (stmt, i); + + /* Skip bound args inserted by Pointer Bounds Checker. */ + if (POINTER_BOUNDS_P (arg)) + continue; + /* If this is a varargs function defer inlining decision to callee. */ if (!p) break; - arg = gimple_call_arg (stmt, i); + if (TREE_VALUE (p) == error_mark_node || arg == error_mark_node || TREE_CODE (TREE_VALUE (p)) == VOID_TYPE || (!types_compatible_p (TREE_VALUE (p), TREE_TYPE (arg)) && !fold_convertible_p (TREE_VALUE (p), arg))) return false; + + p = TREE_CHAIN (p); } } else diff --git a/gcc/gimple.c b/gcc/gimple.c index 20f6010..0fc704b 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -3043,20 +3043,27 @@ canonicalize_cond_expr_cond (tree t) } /* Build a GIMPLE_CALL identical to STMT but skipping the arguments in - the positions marked by the set ARGS_TO_SKIP. */ + the positions marked by the set ARGS_TO_SKIP. ARGS_TO_SKIP does not + take into account bounds arguments. Bounds passed for skipped args + are also skipped. */ gimple gimple_call_copy_skip_args (gimple stmt, bitmap args_to_skip) { - int i; + int i, bit; int nargs = gimple_call_num_args (stmt); vec vargs; vargs.create (nargs); gimple new_stmt; - for (i = 0; i < nargs; i++) - if (!bitmap_bit_p (args_to_skip, i)) - vargs.quick_push (gimple_call_arg (stmt, i)); + for (i = 0, bit = 0; i < nargs; i++, bit++) + if (POINTER_BOUNDS_P (gimple_call_arg (stmt, i))) + { + if (!bitmap_bit_p (args_to_skip, --bit)) + vargs.quick_push (gimple_call_arg (stmt, i)); + } + else if (!bitmap_bit_p (args_to_skip, bit)) + vargs.quick_push (gimple_call_arg (stmt, i)); if (gimple_call_internal_p (stmt)) new_stmt = gimple_build_call_internal_vec (gimple_call_internal_fn (stmt), @@ -3702,6 +3709,9 @@ validate_call (gimple stmt, tree fndecl) if (!targs) return true; tree arg = gimple_call_arg (stmt, i); + /* Skip bounds. */ + if (POINTER_BOUNDS_P (arg)) + continue; if (INTEGRAL_TYPE_P (TREE_TYPE (arg)) && INTEGRAL_TYPE_P (TREE_VALUE (targs))) ;