From patchwork Thu Feb 12 14:14:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 439216 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 BE315140083 for ; Fri, 13 Feb 2015 01:21:38 +1100 (AEDT) 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=CxUvjySxdEh7Gzy0rycyA96zQWxpdmpX0zUVzRE6gjAzlzLul4F+z BrjaMHc1yDMeO4PLww9QimCzqCiQhunZKG8DVWgPgzNrOfpsLDAraezjT1gkGcmT JCxI69kwHI0UduqFIEM7mrlMJgKrdjizdDwJq9Js/JB9Ifhann9I78= 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=PIxWBiWn6+vunrq2okwLCQKpqNs=; b=lsiaLDBjYInQ2j/RdBkh QSiQWhS91BhJWstK+BiA+kifCdIprAaJ1bskR7FAhXrc0oJJ4CU4wBgbuFSCDrMc YPC8grRyHygQ1gFvX53WDpAuTUxxpfQx7Vwfrjy3kY4+JIP3k79JwRy8sjdqhFA7 7PdhwQS9l+v70Q7jJ8nQFHY= Received: (qmail 17606 invoked by alias); 12 Feb 2015 14:14:36 -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 17566 invoked by uid 89); 12 Feb 2015 14:14:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_FROM_URIBL_PCCC, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-ig0-f180.google.com Received: from mail-ig0-f180.google.com (HELO mail-ig0-f180.google.com) (209.85.213.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 12 Feb 2015 14:14:35 +0000 Received: by mail-ig0-f180.google.com with SMTP id b16so3880526igk.1 for ; Thu, 12 Feb 2015 06:14:33 -0800 (PST) X-Received: by 10.43.19.134 with SMTP id qk6mr8623694icb.29.1423750472862; Thu, 12 Feb 2015 06:14:32 -0800 (PST) Received: from msticlxl57.ims.intel.com (fmdmzpr03-ext.fm.intel.com. [192.55.54.38]) by mx.google.com with ESMTPSA id o15sm2470843ioe.22.2015.02.12.06.14.31 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Feb 2015 06:14:32 -0800 (PST) Date: Thu, 12 Feb 2015 17:14:19 +0300 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, PR tree-optimization/65002] Disable SRA for functions wrongly marked as read-only Message-ID: <20150212141419.GA35812@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi, PR65002 is the second issue caused by SRA for functions wrongly marked as read-only. Previous fix for PR64353 doesn't work for this case because SSA update happens too late. Here is a patch to disable SRA for such functions to avoid inconsistent SSA issues. Bootstrapped and tested on x86_64-unknown-linux-gnu. OK for trunk? Thanks, Ilya --- gcc/ 2015-02-12 Ilya Enkovich PR tree-optimization/65002 * tree-cfg.c (pass_data_fixup_cfg): Don't update SSA on start. * tree-sra.c (some_callers_have_no_vuse_p): New. (ipa_early_sra): Reject functions whose callers assume funciton is read only. gcc/testsuite/ 2015-02-12 Ilya Enkovich PR tree-optimization/65002 * gcc.dg/pr65002.C: New. diff --git a/gcc/testsuite/gcc.dg/pr65002.C b/gcc/testsuite/gcc.dg/pr65002.C new file mode 100644 index 0000000..ac7c66b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr65002.C @@ -0,0 +1,26 @@ +/* PR tree-optimization/65002 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +namespace fastmath { + template float floor(const T &) __attribute__((const)); + template float floor(const T &p1) { return p1; } +} +using fastmath::floor; +class A { +public: + A(int, int); + virtual int m_fn1(float) const; +}; +class B : A { +public: + B(int, int p2) : A(entity, p2) {} + int m_fn1(float p1) const { long b(floor(p1)); } + int entity; +}; + +int a; +void Convert() { + if (int *c = 0) + B(*c, a); +} diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 2e23553..006bc08 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -8754,7 +8754,7 @@ const pass_data pass_data_fixup_cfg = PROP_cfg, /* properties_required */ 0, /* properties_provided */ 0, /* properties_destroyed */ - TODO_update_ssa_only_virtuals, /* todo_flags_start */ + 0, /* todo_flags_start */ 0, /* todo_flags_finish */ }; diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index ad9584e..7f78e68 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -4890,6 +4890,20 @@ some_callers_have_mismatched_arguments_p (struct cgraph_node *node, return false; } +/* Return false if all callers have vuse attached to a call statement. */ + +static bool +some_callers_have_no_vuse_p (struct cgraph_node *node, + void *data ATTRIBUTE_UNUSED) +{ + struct cgraph_edge *cs; + for (cs = node->callers; cs; cs = cs->next_caller) + if (!cs->call_stmt || !gimple_vuse (cs->call_stmt)) + return true; + + return false; +} + /* Convert all callers of NODE. */ static bool @@ -5116,6 +5130,15 @@ ipa_early_sra (void) goto simple_out; } + if (node->call_for_symbol_thunks_and_aliases + (some_callers_have_no_vuse_p, NULL, true)) + { + if (dump_file) + fprintf (dump_file, "There are callers with no VUSE attached " + "to a call stmt.\n"); + goto simple_out; + } + bb_dereferences = XCNEWVEC (HOST_WIDE_INT, func_param_count * last_basic_block_for_fn (cfun));