From patchwork Thu Oct 31 09:02:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 287430 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2876D2C008A for ; Thu, 31 Oct 2013 20:03:02 +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:subject:message-id:mime-version:content-type; q=dns; s= default; b=oXqRFzczKQ7M0uj9BpcJVKK6ArQCL3i6lQZj6+yVmzL3L4KFwBmOf X5S/FDy+ELxwGzKEnin0XUxHv5Nq7aYY6d4mIMfqcGgblp6zlvPiRq5JAcOHVr8Z PcuAEPK8lBPZxQjPr/SoRFa21aN90omDQfhocF4ds1YPDmLk6i5IBs= 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:subject:message-id:mime-version:content-type; s= default; bh=qXXLgQ2b97/MIRafwEZAMmV644g=; b=pbwa+dwZk7WNhsWb6pLt lwxxB7EKwQ5l8aZ6KsyflLiHoUG9rD0nSs6qq22AN2/Y6bydOzBmk0c41iJQfJze v0P3vX7982c5GZTYUEf7MfmLJwjbuIzWhnAbRHc5+7qgfOD+hWcIoJJytvvOzk2p puBMy+ujufxCVZWKZDQ9uv0= Received: (qmail 15360 invoked by alias); 31 Oct 2013 09:02: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 15351 invoked by uid 89); 31 Oct 2013 09:02:56 -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, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f182.google.com Received: from mail-pd0-f182.google.com (HELO mail-pd0-f182.google.com) (209.85.192.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 31 Oct 2013 09:02:55 +0000 Received: by mail-pd0-f182.google.com with SMTP id q10so2104553pdj.27 for ; Thu, 31 Oct 2013 02:02:53 -0700 (PDT) X-Received: by 10.68.211.202 with SMTP id ne10mr726774pbc.168.1383210173197; Thu, 31 Oct 2013 02:02:53 -0700 (PDT) Received: from msticlxl57.ims.intel.com (fmdmzpr03-ext.fm.intel.com. [192.55.54.38]) by mx.google.com with ESMTPSA id sd3sm2678400pbb.42.2013.10.31.02.02.51 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 31 Oct 2013 02:02:52 -0700 (PDT) Date: Thu, 31 Oct 2013 13:02:13 +0400 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, MPX, 2/X] Pointers Checker [7/25] Suppress BUILT_IN_CHKP_ARG_BND optimizations. Message-ID: <20131031090213.GC54327@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi, Here is a patch which hadles the problem with optimization of BUILT_IN_CHKP_ARG_BND calls. Pointer Bounds Checker expects that argument of this call is a default SSA_NAME of the PARM_DECL whose bounds we want to get. The problem is in optimizations which may replace arg with it's copy or a known value. This patch suppress such modifications. Thanks, Ilya --- gcc/ 2013-10-28 Ilya Enkovich * tree-into-ssa.c: Include "target.h" (rewrite_update_stmt): Skip BUILT_IN_CHKP_ARG_BND calls. * tree-ssa-dom.c: Include "target.h" (cprop_into_stmt): Skip BUILT_IN_CHKP_ARG_BND calls. diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index 981e9f4..8d48f6d 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see #include "params.h" #include "diagnostic-core.h" #include "tree-into-ssa.h" +#include "target.h" /* This file builds the SSA form for a function as described in: @@ -1921,8 +1922,14 @@ rewrite_update_stmt (gimple stmt, gimple_stmt_iterator gsi) } /* Rewrite USES included in OLD_SSA_NAMES and USES whose underlying - symbol is marked for renaming. */ - if (rewrite_uses_p (stmt)) + symbol is marked for renaming. + Skip calls to BUILT_IN_CHKP_ARG_BND whose arg should never be + renamed. */ + if (rewrite_uses_p (stmt) + && !(flag_check_pointer_bounds + && (gimple_code (stmt) == GIMPLE_CALL) + && gimple_call_fndecl (stmt) + == targetm.builtin_chkp_function (BUILT_IN_CHKP_ARG_BND))) { if (is_gimple_debug (stmt)) { diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 211bfcf..445278a 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -45,6 +45,7 @@ along with GCC; see the file COPYING3. If not see #include "params.h" #include "tree-ssa-threadedge.h" #include "tree-ssa-dom.h" +#include "target.h" /* This file implements optimizations on the dominator tree. */ @@ -2266,6 +2267,16 @@ cprop_into_stmt (gimple stmt) use_operand_p op_p; ssa_op_iter iter; + /* Call used to obtain bounds of input arg by Pointer Bounds Checker + should not be optimized. Argument of the call is a default + SSA_NAME of PARM_DECL. It should never be replaced by value. */ + if (flag_check_pointer_bounds && gimple_code (stmt) == GIMPLE_CALL) + { + tree fndecl = gimple_call_fndecl (stmt); + if (fndecl == targetm.builtin_chkp_function (BUILT_IN_CHKP_ARG_BND)) + return; + } + FOR_EACH_SSA_USE_OPERAND (op_p, stmt, iter, SSA_OP_USE) cprop_operand (stmt, op_p); }