From patchwork Mon Oct 13 10:53:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 399146 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 18E711400B0 for ; Mon, 13 Oct 2014 21:54:16 +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=pSTy5A18flwG8CYKf HDVxDoxc3Ey5bdWWCVBC7nC9QbUVay8a+bwKd3wAUbhEanPGyaQfc5Vw58AYoSWT /4NecIlwQTrB+srvbu+k3VPdYm+ghDjYwv9Fhkhe0cra8eV197kHOyWJqsywPlEW fyljHaC1ffpRM9r58Ey8RCH8M4= 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=RAJekzaPFYbmFoZI+K/5imG f/h8=; b=Xq9HY+w+7S2qJG66TY9JVzw06mOSfuP+irydfCCvLEjKHVTAnJLNh2v 8uig2Nb0FdmKo+9hCHDNqkIsOb92La9T57ZQOGPW2w/KoqbGNMpyIRrKcSq9FKez 2UiZvinQlVMOXNgXCcc9g1cRuFtOJZpFJkIVFWgpIioj/BPtcsvE= Received: (qmail 29873 invoked by alias); 13 Oct 2014 10:53:44 -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 29812 invoked by uid 89); 13 Oct 2014 10:53:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f42.google.com Received: from mail-pa0-f42.google.com (HELO mail-pa0-f42.google.com) (209.85.220.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 13 Oct 2014 10:53:42 +0000 Received: by mail-pa0-f42.google.com with SMTP id bj1so5756551pad.1 for ; Mon, 13 Oct 2014 03:53:40 -0700 (PDT) X-Received: by 10.66.228.166 with SMTP id sj6mr21866479pac.26.1413197620524; Mon, 13 Oct 2014 03:53:40 -0700 (PDT) Received: from msticlxl57.ims.intel.com ([192.55.54.42]) by mx.google.com with ESMTPSA id mu10sm10933591pdb.10.2014.10.13.03.53.38 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Oct 2014 03:53:40 -0700 (PDT) Date: Mon, 13 Oct 2014 14:53:34 +0400 From: Ilya Enkovich To: Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH, Pointer Bounds Checker 14/x] Passes [7/n] Instrument params Message-ID: <20141013105334.GC62841@msticlxl57.ims.intel.com> References: <20141008190637.GG13454@msticlxl57.ims.intel.com> <5438210A.9090200@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5438210A.9090200@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes On 10 Oct 12:10, Jeff Law wrote: > On 10/08/14 13:06, Ilya Enkovich wrote: > >Hi, > > > >This patch adds bounds initialization for address taken input arguments. > > > >Thanks, > >Ilya > >-- > >2014-10-08 Ilya Enkovich > > > > * tree-chkp.c (chkp_instrument_function): Store bounds for > > address taken args. > > > > > >diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c > >index 6bbceb0..5443950 100644 > >--- a/gcc/tree-chkp.c > >+++ b/gcc/tree-chkp.c > >@@ -3758,6 +3758,51 @@ chkp_instrument_function (void) > > bb = next; > > } > > while (bb); > >+ > >+ /* Some input params may have bounds and be address taken. In this case > >+ we should store incomping bounds into bounds table. */ > s/incomping/incoming/ > > With that nit fixed this is OK. > > jeff > Here is a fixed version. Thanks, Ilya diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index 0d4577d1..53b3386 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -3758,6 +3758,51 @@ chkp_instrument_function (void) bb = next; } while (bb); + + /* Some input params may have bounds and be address taken. In this case + we should store incoming bounds into bounds table. */ + tree arg; + if (flag_chkp_store_bounds) + for (arg = DECL_ARGUMENTS (cfun->decl); arg; arg = DECL_CHAIN (arg)) + if (TREE_ADDRESSABLE (arg)) + { + if (BOUNDED_P (arg)) + { + tree bounds = chkp_get_next_bounds_parm (arg); + tree def_ptr = ssa_default_def (cfun, arg); + gimple_stmt_iterator iter + = gsi_start_bb (chkp_get_entry_block ()); + chkp_build_bndstx (chkp_build_addr_expr (arg), + def_ptr ? def_ptr : arg, + bounds, &iter); + + /* Skip bounds arg. */ + arg = TREE_CHAIN (arg); + } + else if (chkp_type_has_pointer (TREE_TYPE (arg))) + { + tree orig_arg = arg; + bitmap slots = chkp_find_bound_slots (TREE_TYPE (arg)); + gimple_stmt_iterator iter + = gsi_start_bb (chkp_get_entry_block ()); + bitmap_iterator bi; + unsigned bnd_no; + + EXECUTE_IF_SET_IN_BITMAP (slots, 0, bnd_no, bi) + { + tree bounds = chkp_get_next_bounds_parm (arg); + HOST_WIDE_INT offs = bnd_no * POINTER_SIZE / BITS_PER_UNIT; + tree addr = chkp_build_addr_expr (orig_arg); + tree ptr = build2 (MEM_REF, ptr_type_node, addr, + build_int_cst (ptr_type_node, offs)); + chkp_build_bndstx (chkp_build_addr_expr (ptr), ptr, + bounds, &iter); + + arg = DECL_CHAIN (arg); + } + BITMAP_FREE (slots); + } + } } /* Initialize pass. */