From patchwork Wed Jun 12 12:33:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 250753 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 CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 9193B2C0085 for ; Wed, 12 Jun 2013 22:33:10 +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:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=h3NovGIJdHTEK47LStXFkZCiD46QQsK3wGHVs0kC3kMqKbfOE5 89pSXFK4GwcsvyrNzLJPQGLD0WNLkPx+WN5w0nciRIf+FkWWivPAAdroya5hkWs1 MC2Cp9QUj8enZdL9nDEY/81wyVqL5KQcOqbdT0vQaq3fM2FyrKxqRYJd0= 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=joHb373bVVvKcmCVXCUjkfiWRt0=; b=HaFanhoRj+qA3swn40oO ombEbsYa6qEgd6EPDyOamHmITodd5iyZ4QyqJ5mMARsD366QrZziHrb/AFEuHuz8 w2dbMIHcp9U1TNaLjqy4mO0WqLmKGEyh4Xp1HGCQDPVwf6ZMpPfBedKc/DN5YteV 0WmBmrLA+Vnk21WGX0wO2jc= Received: (qmail 25503 invoked by alias); 12 Jun 2013 12:33:04 -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 25484 invoked by uid 89); 12 Jun 2013 12:33:04 -0000 X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL autolearn=ham version=3.3.1 Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 12 Jun 2013 12:33:03 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3FB60A5429; Wed, 12 Jun 2013 14:33:01 +0200 (CEST) Date: Wed, 12 Jun 2013 14:33:00 +0200 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PATCH, trunk, PR57358] Avoid IPA-CP analysis if attribute optimize precludes it Message-ID: <20130612123300.GE26236@virgil.suse> Mail-Followup-To: GCC Patches , Jan Hubicka MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi, this is how I would like to fix the ICE when analyzing a function with attribute optimize on trunk. Inlining, the other user of the analysis, is already smart enough not to analyze such functions, so this teaches IPA-CP to do the same thing. Consequently, functions witrh attribute optimize(O0) or even optimize(fno-ipa-cp) will be completely ignored by IPA-CP and friends, making it completely opaque black box during the analysis. It is a tiny bit more efficient than the simple fix for the branch (but changes compiler behavior). I assume it can also come handy during some debugging/analysis. Bootstrapped and tested on x86_64-linux. OK for trunk? Thanks, Martin 2013-06-11 Martin Jambor PR tree-optimization/57358 * ipa-prop.c (ipa_func_spec_opts_forbid_analysis_p): New function. (ipa_compute_jump_functions_for_edge): Bail out if it returns true. (ipa_analyze_params_uses): Generate pessimistic info when true. testsuite * gcc.dg/ipa/pr57358.c: New test. Index: src/gcc/ipa-prop.c =================================================================== --- src.orig/gcc/ipa-prop.c +++ src/gcc/ipa-prop.c @@ -78,6 +78,21 @@ struct ipa_cst_ref_desc static alloc_pool ipa_refdesc_pool; +/* Return true if DECL_FUNCTION_SPECIFIC_OPTIMIZATION of the decl associated + with NODE should prevent us from analyzing it for the purposes of IPA-CP. */ + +static bool +ipa_func_spec_opts_forbid_analysis_p (struct cgraph_node *node) +{ + tree fs_opts = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (node->symbol.decl); + struct cl_optimization *os; + + if (!fs_opts) + return false; + os = TREE_OPTIMIZATION (fs_opts); + return !os->x_optimize || !os->x_flag_ipa_cp; +} + /* Return index of the formal whose tree is PTREE in function which corresponds to INFO. */ @@ -1446,6 +1461,9 @@ ipa_compute_jump_functions_for_edge (str return; vec_safe_grow_cleared (args->jump_functions, arg_num); + if (ipa_func_spec_opts_forbid_analysis_p (cs->caller)) + return; + for (n = 0; n < arg_num; n++) { struct ipa_jump_func *jfunc = ipa_get_ith_jump_func (args, n); @@ -1936,6 +1954,17 @@ ipa_analyze_params_uses (struct cgraph_n if (ipa_get_param_count (info) == 0 || info->uses_analysis_done) return; + info->uses_analysis_done = 1; + if (ipa_func_spec_opts_forbid_analysis_p (node)) + { + for (i = 0; i < ipa_get_param_count (info); i++) + { + ipa_set_param_used (info, i, true); + ipa_set_controlled_uses (info, i, IPA_UNDESCRIBED_USE); + } + return; + } + for (i = 0; i < ipa_get_param_count (info); i++) { tree parm = ipa_get_param (info, i); @@ -1992,8 +2021,6 @@ ipa_analyze_params_uses (struct cgraph_n visit_ref_for_mod_analysis, visit_ref_for_mod_analysis); } - - info->uses_analysis_done = 1; } /* Free stuff in PARMS_AINFO, assume there are PARAM_COUNT parameters. */ Index: src/gcc/testsuite/gcc.dg/ipa/pr57358.c =================================================================== --- /dev/null +++ src/gcc/testsuite/gcc.dg/ipa/pr57358.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct t { void (*func)(void*); }; +void test_func(struct t* a) __attribute__((optimize("O0"))); +void test_func(struct t* a) +{ + a->func(0); +}