From patchwork Wed Oct 8 19:12:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 397697 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 D9A121400E0 for ; Thu, 9 Oct 2014 06:13:03 +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:mime-version:content-type; q=dns; s=default; b=Md9P6MahpluY7ckMmGniAFg1ryOsB1wcWz6X5kykyi6McZNlai jvj2sArQPKHTjc2IZedrfjHpx+UrXTeEdczmu1Bo6RFCXf7I6kVC6EXsbmlNYLkK e4xEeC4kTquQPIoZ6X+FPvSl5/FEKVpjK9fjsYRLfHUTslBGbu/Daur/8= 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:mime-version:content-type; s= default; bh=250Mfl8Zss1HgXIlryhEfaWmmZ4=; b=fp9Y8296LJmLhe+S5S4M EUMU/gqk4yovp+lhVNSBQxDt/l4PrKQxhe/QFc8oawaxFciOL9bsosVyAVOHNlhy LFdeXOpKxtaa4wFGXUwEnBPo32rAegZ+1ZdC5gpv4GQMY3pBsKEWIle4a70Lq7NN v1Zi2tg0PMs3Qhx+UpCDnqs= Received: (qmail 12001 invoked by alias); 8 Oct 2014 19:12:56 -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 11987 invoked by uid 89); 8 Oct 2014 19:12:55 -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-pd0-f172.google.com Received: from mail-pd0-f172.google.com (HELO mail-pd0-f172.google.com) (209.85.192.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 08 Oct 2014 19:12:54 +0000 Received: by mail-pd0-f172.google.com with SMTP id ft15so7411041pdb.3 for ; Wed, 08 Oct 2014 12:12:53 -0700 (PDT) X-Received: by 10.66.216.195 with SMTP id os3mr3526494pac.144.1412795573214; Wed, 08 Oct 2014 12:12:53 -0700 (PDT) Received: from msticlxl57.ims.intel.com (fmdmzpr01-ext.fm.intel.com. [192.55.54.36]) by mx.google.com with ESMTPSA id yh3sm697429pbb.38.2014.10.08.12.12.51 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Oct 2014 12:12:52 -0700 (PDT) Date: Wed, 8 Oct 2014 23:12:47 +0400 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Cc: Jeff Law Subject: [PATCH, Pointer Bounds Checker 14/x] Passes [10/n] Stores handler Message-ID: <20141008191247.GJ13454@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi, This patch adds an assignment processing function which is used by lnliner for newly generated stores. Thanks, Ilya --- 2014-10-08 Ilya Enkovich * tree-chkp.c (chkp_copy_bounds_for_assign): New. * tree-chkp.h (chkp_copy_bounds_for_assign): New. diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index 4b5a773..6f73699 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -3781,6 +3781,43 @@ chkp_process_stmt (gimple_stmt_iterator *iter, tree node, } } +/* Add code to copy bounds for all pointers copied + in ASSIGN created during inline of EDGE. */ +void +chkp_copy_bounds_for_assign (gimple assign, struct cgraph_edge *edge) +{ + tree lhs = gimple_assign_lhs (assign); + tree rhs = gimple_assign_rhs1 (assign); + gimple_stmt_iterator iter = gsi_for_stmt (assign); + + if (!flag_chkp_store_bounds) + return; + + chkp_walk_pointer_assignments (lhs, rhs, &iter, chkp_copy_bounds_for_elem); + + /* We should create edges for all created calls to bndldx and bndstx. */ + while (gsi_stmt (iter) != assign) + { + gimple stmt = gsi_stmt (iter); + if (gimple_code (stmt) == GIMPLE_CALL) + { + tree fndecl = gimple_call_fndecl (stmt); + struct cgraph_node *callee = cgraph_node::get_create (fndecl); + struct cgraph_edge *new_edge; + + gcc_assert (fndecl == chkp_bndstx_fndecl + || fndecl == chkp_bndldx_fndecl + || fndecl == chkp_ret_bnd_fndecl); + + new_edge = edge->caller->create_edge (callee, stmt, edge->count, + edge->frequency); + new_edge->frequency = compute_call_stmt_bb_frequency + (edge->caller->decl, gimple_bb (stmt)); + } + gsi_prev (&iter); + } +} + /* Some code transformation made during instrumentation pass may put code into inconsistent state. Here we find and fix such flaws. */ diff --git a/gcc/tree-chkp.h b/gcc/tree-chkp.h index 81306ba..9a3c55d 100644 --- a/gcc/tree-chkp.h +++ b/gcc/tree-chkp.h @@ -46,6 +46,8 @@ extern void chkp_build_bndstx (tree addr, tree ptr, tree bounds, extern gimple chkp_retbnd_call_by_val (tree val); extern bool chkp_function_instrumented_p (tree fndecl); extern void chkp_function_mark_instrumented (tree fndecl); +extern void chkp_copy_bounds_for_assign (gimple assign, + struct cgraph_edge *edge); extern bool chkp_gimple_call_builtin_p (gimple call, enum built_in_function code); extern void chkp_expand_bounds_reset_for_mem (tree mem, tree ptr);