From patchwork Thu May 29 10:53:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 353725 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 F32AE140098 for ; Thu, 29 May 2014 20:54:15 +1000 (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=AJK0+306zViNlB8LN0Yhgv6QqIQjTRA471MaQPRc356S16ZBLzKTD ll898KsNE7BcnzJo2RTdxwKEhIgouidTQUV+3N2niI6S9MR/OL5PxKZn/ec244VN WQtYxdWHtqA/bYhpRs1dx3BTqBtaGt7Zi3WYQzVxc0Bp/EGLOUI264= 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=CJg2tNS68wouRpvbPmoiZJGkpqM=; b=mLUNTqOmBw2pGRahYJQS jQhp9/ymvP/uYXcN5Ass4Lp0bO7zrsBdZmFLzxkaqdqYpjzHkazItZ1HimDPJFW4 VT3emcZ9/3FA/NTtQOhvnqtMgDALYggz4Ifcfmi6VsrTlwT2AqMIn+cYX/rHpTiC mRC7gkOrkwIXs5IWFFmc7DI= Received: (qmail 4153 invoked by alias); 29 May 2014 10:54:09 -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 4142 invoked by uid 89); 29 May 2014 10:54:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pb0-f45.google.com Received: from mail-pb0-f45.google.com (HELO mail-pb0-f45.google.com) (209.85.160.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 29 May 2014 10:54:07 +0000 Received: by mail-pb0-f45.google.com with SMTP id um1so178741pbc.32 for ; Thu, 29 May 2014 03:54:05 -0700 (PDT) X-Received: by 10.67.4.169 with SMTP id cf9mr7466305pad.45.1401360845448; Thu, 29 May 2014 03:54:05 -0700 (PDT) Received: from msticlxl57.ims.intel.com (fmdmzpr01-ext.fm.intel.com. [192.55.54.36]) by mx.google.com with ESMTPSA id x5sm634829pbw.26.2014.05.29.03.54.03 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 May 2014 03:54:04 -0700 (PDT) Date: Thu, 29 May 2014 14:53:55 +0400 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, i386, Pointer Bounds Checker 11/x] Keep bounds initial values Message-ID: <20140529095256.GA44227@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 tries to keep bounds initial values when it may be needed. Even if initial value is not fully known (e.g. we know only low bound) it still may help to remove some redundant checks. Bootstrapped and tested on linux-x86_64. Thanks, Ilya --- gcc/ 2013-05-29 Ilya Enkovich * ipa.c (symtab_remove_unreachable_nodes): Kepp initial values for pointer bounds to be used for checks eliminations. * lto-cgraph.c (compute_ltrans_boundary): Likewise. * add_references_to_partition (add_references_to_partition): Add references to pointer bounds vars. diff --git a/gcc/ipa.c b/gcc/ipa.c index 1d7fa35..958cabe 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -568,7 +568,8 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) vnode->aux = NULL; /* Keep body if it may be useful for constant folding. */ - if ((init = ctor_for_folding (vnode->decl)) == error_mark_node) + if ((init = ctor_for_folding (vnode->decl)) == error_mark_node + && !POINTER_BOUNDS_P (vnode->decl)) varpool_remove_initializer (vnode); else DECL_INITIAL (vnode->decl) = init; diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index 58105f0..7089516 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -829,7 +829,8 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder) { if (!lto_symtab_encoder_encode_initializer_p (encoder, vnode) - && ctor_for_folding (vnode->decl) != error_mark_node) + && (ctor_for_folding (vnode->decl) != error_mark_node + || POINTER_BOUNDS_P (vnode->decl))) { lto_set_symtab_encoder_encode_initializer (encoder, vnode); add_references (encoder, &vnode->ref_list); diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c index 2967d73..330253b 100644 --- a/gcc/lto/lto-partition.c +++ b/gcc/lto/lto-partition.c @@ -96,7 +96,8 @@ add_references_to_partition (ltrans_partition part, symtab_node *node) Recursively look into the initializers of the constant variable and add references, too. */ else if (is_a (ref->referred) - && ctor_for_folding (ref->referred->decl) != error_mark_node + && (ctor_for_folding (ref->referred->decl) != error_mark_node + || POINTER_BOUNDS_P (ref->referred->decl)) && !lto_symtab_encoder_in_partition_p (part->encoder, ref->referred)) { if (!part->initializers_visited)