From patchwork Sun Nov 15 11:03:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 544819 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 039DB1402B3 for ; Sun, 15 Nov 2015 22:04:06 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=CEVL96m3; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=Exh/rrVwIvF71/HH8 5PEI3LSYf9je5pVrI0kpkr3mYGjIgg7Fx/EaIkhXJZ0o/5R6bsBs0faBbThqBT+9 x0p6Tifvnwlm5xV4JPZaMtxzLFwva00c5zb7F7/OrQsUeCRAEtAuuJSU7KNJC3+w zDUYE5tJ/t/Xrzg9zN9J22yr5c= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=fe/iMGK6B6WcVwtWWC2o+ee rYWA=; b=CEVL96m3LokFlDB6WbphPTa0qG+Pfa2+wuy7HAPuJignwbdtLbFrwbk xTHQoHZ1Ff38OnNjX6Vyb9DxtpPQY2Hs/6nEZgxgwqsbcOFFNe6QwkzwY0uxXGzH 50RBOcPwi5X6zvKCmPK4AFY+lfJlDV4Fy/XzXzbbjOBQKXMVTH6c= Received: (qmail 16090 invoked by alias); 15 Nov 2015 11:03:57 -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 16073 invoked by uid 89); 15 Nov 2015 11:03:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 15 Nov 2015 11:03:54 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45329) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1Zxv67-0007IE-1P for gcc-patches@gnu.org; Sun, 15 Nov 2015 06:03:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zxv61-0008IM-P5 for gcc-patches@gnu.org; Sun, 15 Nov 2015 06:03:50 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:57945) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zxv61-0008Hw-GO for gcc-patches@gnu.org; Sun, 15 Nov 2015 06:03:45 -0500 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Zxv60-0007kf-Mx from Tom_deVries@mentor.com ; Sun, 15 Nov 2015 03:03:45 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Sun, 15 Nov 2015 11:03:43 +0000 Subject: [PATCH, 4/6] Remove first_pass_instance from pass_object_sizes To: Richard Biener References: <56447A09.4070608@mentor.com> <564498CE.5010207@mentor.com> <1447342432.7830.21.camel@surprise> <5645EC5A.9060005@mentor.com> <5646FC85.2060802@mentor.com> <564864AA.6000101@mentor.com> CC: David Malcolm , "gcc-patches@gnu.org" From: Tom de Vries Message-ID: <5648666E.3050108@mentor.com> Date: Sun, 15 Nov 2015 12:03:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <564864AA.6000101@mentor.com> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 On 15/11/15 11:55, Tom de Vries wrote: > [ was: Re: [PATCH] Remove first_pass_instance from pass_vrp ] > > This patch series removes first_pass_instance. > > 1 Remove first_pass_instance from pass_vrp > 2 Remove first_pass_instance from pass_reassoc > 3 Remove first_pass_instance from pass_dominator > 4 Remove first_pass_instance from pass_object_sizes > 5 Remove first_pass_instance from pass_ccp > 6 Remove first_pass_instance > > Bootstrapped and reg-tested on x86_64. > > I will post the individual patches in reply to this email. > > [ I won't post the first patch though. It was already posted here: > https://gcc.gnu.org/ml/gcc-patches/2015-11/msg01701.html . ] this patches removes first_pass_instance from pass_object_sizes. Thanks, - Tom Remove first_pass_instance from pass_object_sizes 2015-11-15 Tom de Vries * passes.def: Add arg to pass_object_sizes pass instantiation. * tree-object-size.c (pass_object_sizes::pass_object_sizes): Initialize insert_min_max_p. (pass_object_sizes::set_pass_param): New member function. Set insert_min_max_p. (pass_object_sizes::insert_min_max_p): New private member. (pass_object_sizes::execute): Use insert_min_max_p instead of first_pass_instance. --- gcc/passes.def | 4 ++-- gcc/tree-object-size.c | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gcc/passes.def b/gcc/passes.def index d274a95..64883a7 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -77,7 +77,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_all_early_optimizations); PUSH_INSERT_PASSES_WITHIN (pass_all_early_optimizations) NEXT_PASS (pass_remove_cgraph_callee_edges); - NEXT_PASS (pass_object_sizes); + NEXT_PASS (pass_object_sizes, true /* insert_min_max_p */); NEXT_PASS (pass_ccp); /* After CCP we rewrite no longer addressed locals into SSA form if possible. */ @@ -164,7 +164,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_backprop); NEXT_PASS (pass_phiprop); NEXT_PASS (pass_forwprop); - NEXT_PASS (pass_object_sizes); + NEXT_PASS (pass_object_sizes, false /* insert_min_max_p */); /* pass_build_alias is a dummy pass that ensures that we execute TODO_rebuild_alias at this point. */ NEXT_PASS (pass_build_alias); diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c index fa3625c..459e65d 100644 --- a/gcc/tree-object-size.c +++ b/gcc/tree-object-size.c @@ -1217,13 +1217,21 @@ class pass_object_sizes : public gimple_opt_pass { public: pass_object_sizes (gcc::context *ctxt) - : gimple_opt_pass (pass_data_object_sizes, ctxt) + : gimple_opt_pass (pass_data_object_sizes, ctxt), insert_min_max_p (false) {} /* opt_pass methods: */ opt_pass * clone () { return new pass_object_sizes (m_ctxt); } + void set_pass_param (unsigned int n, bool param) + { + gcc_assert (n == 0); + insert_min_max_p = param; + } virtual unsigned int execute (function *); + private: + /* Determines whether the pass instance creates MIN/MAX_EXPRs. */ + bool insert_min_max_p; }; // class pass_object_sizes /* Dummy valueize function. */ @@ -1250,12 +1258,12 @@ pass_object_sizes::execute (function *fun) init_object_sizes (); - /* In the first pass instance, only attempt to fold + /* If insert_min_max_p, only attempt to fold __builtin_object_size (x, 1) and __builtin_object_size (x, 3), and rather than folding the builtin to the constant if any, create a MIN_EXPR or MAX_EXPR of the __builtin_object_size call result and the computed constant. */ - if (first_pass_instance) + if (insert_min_max_p) { tree ost = gimple_call_arg (call, 1); if (tree_fits_uhwi_p (ost))