From patchwork Mon Nov 18 10:58:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 292023 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 8B8752C0109 for ; Mon, 18 Nov 2013 21:59:10 +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=L1uHW1laIe0H6Bkuz3c2lekWJcsIBet5pvf/OlvPJ4hyXjrjkjllN 2cYphbMB3LXhLPmKhp0EAOgCwW3Of578pk7cs0JMlBODONh5HWDm9LoeX/FAo6+P HFFjjBpg6/T0moCklfdVGzEZ9TZ0C3twNa/P/7uQBS1uWtDSv6mAJ8= 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=tn+oRP+i1QeGrfSj5rERyyY/IDU=; b=SXjwwkfctDiHMTGVsY8s lh9eECaUdZKHLJWtlf+Qcv8ok0WM3BJzBvbltXH90XkEkXGRFTqVQuENoHnYSdmk rc3mbpwBqE5Q2wLPVQXRD4F+1pJZf1E2cJmIdc+vbaDhy2SKqwip1YlpqcOiZCn7 XF+fWL8uL1vgnpJGcTC3IE0= Received: (qmail 17721 invoked by alias); 18 Nov 2013 10:58:59 -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 17710 invoked by uid 89); 18 Nov 2013 10:58:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.5 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RDNS_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mail-pd0-f180.google.com Received: from Unknown (HELO mail-pd0-f180.google.com) (209.85.192.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 18 Nov 2013 10:58:58 +0000 Received: by mail-pd0-f180.google.com with SMTP id q10so1223434pdj.11 for ; Mon, 18 Nov 2013 02:58:50 -0800 (PST) X-Received: by 10.66.216.162 with SMTP id or2mr401166pac.179.1384772330062; Mon, 18 Nov 2013 02:58:50 -0800 (PST) Received: from msticlxl57.ims.intel.com (fmdmzpr03-ext.fm.intel.com. [192.55.54.38]) by mx.google.com with ESMTPSA id kd1sm25727631pab.20.2013.11.18.02.58.48 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 18 Nov 2013 02:58:49 -0800 (PST) Date: Mon, 18 Nov 2013 14:58:05 +0400 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, MPX, 2/X] Pointers Checker [19/25] Strchr Message-ID: <20131118105805.GM21297@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 to replace BUILT_IN_CHKP_BNDRET with assignment when optimizing strchr. Thanks, Ilya --- 2013-11-13 Ilya Enkovich * tree-ssa-strlen.c: Include tree-chkp.h. (handle_builtin_strchr): Remove retbnd call when strchr call is removed. diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index cfd7b00..711f5d7 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-pretty-print.h" #include "params.h" #include "expr.h" +#include "tree-chkp.h" /* A vector indexed by SSA_NAME_VERSION. 0 means unknown, positive value is an index into strinfo vector, negative value stands for @@ -961,6 +962,8 @@ handle_builtin_strchr (gimple_stmt_iterator *gsi) tree src; gimple stmt = gsi_stmt (*gsi); tree lhs = gimple_call_lhs (stmt); + gimple retbnd_stmt = NULL; + tree retbnd = NULL; if (lhs == NULL_TREE) return; @@ -1009,6 +1012,14 @@ handle_builtin_strchr (gimple_stmt_iterator *gsi) TREE_TYPE (rhs))) rhs = fold_convert_loc (loc, TREE_TYPE (lhs), rhs); } + + /* Remember passed and returned bounds if any. */ + if (gimple_call_with_bounds_p (stmt)) + { + retbnd = chkp_get_call_arg_bounds (gimple_call_arg (stmt, 0)); + retbnd_stmt = chkp_retbnd_call_by_val (lhs); + } + if (!update_call_from_tree (gsi, rhs)) gimplify_and_update_call_from_tree (gsi, rhs); stmt = gsi_stmt (*gsi); @@ -1018,6 +1029,18 @@ handle_builtin_strchr (gimple_stmt_iterator *gsi) fprintf (dump_file, "into: "); print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM); } + + /* Replace retbnd call with assignment. */ + if (retbnd_stmt) + { + gimple_stmt_iterator ret_gsi = gsi_for_stmt (retbnd_stmt); + + if (!update_call_from_tree (&ret_gsi, retbnd)) + gimplify_and_update_call_from_tree (&ret_gsi, retbnd); + retbnd_stmt = gsi_stmt (ret_gsi); + update_stmt (retbnd_stmt); + } + if (si != NULL && si->endptr == NULL_TREE && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs))