From patchwork Mon Apr 14 17:36:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 339024 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 2667514008F for ; Tue, 15 Apr 2014 03:36:58 +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=oaM/bOz5b2uqyO9LacI+ygkDaV3WyTqqQmToKGUJ2dC1/wxP7p AMVOgL3Us2DhhgSFz+8rTAxnJO9mLKJXbDwIsnUGNxUcw6bqbyFWCnmBuozbYubT inbtwWG9zQBhkBuXmiDQnuSq8u/6yo6KCjahEVxmQteyXNi7c+jNgVues= 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=oQwKKBpnaE3EMdtYbF29eCxuRFA=; b=P6AzFcEBH2gJ6ix6b2C/ n1rxQ+ZDVJf6tutZnCTRUMr1f2jwtJgWG+TTa75EafJAIImEWps9MCzn4oMP9snn wAlfyoF5gV/J+zZmubLHfAGybLLVzrQl3iFLWNPMcHJU+qXT3hJa4ho8rOOklU89 CQSZ6KIF/cFWdhIUSQiPhus= Received: (qmail 4386 invoked by alias); 14 Apr 2014 17:36:52 -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 4376 invoked by uid 89); 14 Apr 2014 17:36:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 14 Apr 2014 17:36:49 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A865AAB0E; Mon, 14 Apr 2014 17:36:46 +0000 (UTC) Date: Mon, 14 Apr 2014 19:36:46 +0200 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PATCH] Do not run IPA transform phases multiple times Message-ID: <20140414173646.GE8020@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) X-IsSubscribed: yes Hi, I have noticed that we often run IPA-transformation phases multiple times. The reason is that when a virtual clone is created, it starts with an empty ipa_transforms_to_apply vector and all subsequent IPA passes that see it are pushed onto it. The original node gets these pushed on their ipa_transforms_to_apply too. Later on, when a clone receives its body, in tree_function_versioning, the contents of original node's ipa_transforms_to_apply is added to clone's ipa_transforms_to_apply (in a slightly convoluted way). I do not understand how this was supposed to work but obviously we can and do end up with multiple copies of a few passes in ipa_transforms_to_apply of the clone. I believe the correct thing to do is to copy the vector when the virtual clone is created and remove the part in tree_function_versioning that does the copying. I have verified that we no longer call transformation of IPA-CP multiple times when we previously did and added asserts to check that no other caller of tree_function_versioning expects to have the vector copied. Bootstrapped and tested on x86_64-linux, OK for trunk? Thanks, Martin 2014-04-10 Martin Jambor * cgraphclones.c (cgraph_create_virtual_clone): Duplicate ipa_transforms_to_apply. (cgraph_function_versioning): Assert that old_node has empty ipa_transforms_to_apply. * trans-mem.c (ipa_tm_create_version): Likewise. * tree-inline.c (tree_function_versioning): Do not duplicate ipa_transforms_to_apply. Index: src/gcc/cgraphclones.c =================================================================== --- src.orig/gcc/cgraphclones.c +++ src/gcc/cgraphclones.c @@ -600,6 +600,9 @@ cgraph_create_virtual_clone (struct cgra } else new_node->clone.combined_args_to_skip = args_to_skip; + if (old_node->ipa_transforms_to_apply.exists ()) + new_node->ipa_transforms_to_apply + = old_node->ipa_transforms_to_apply.copy (); cgraph_call_node_duplication_hooks (old_node, new_node); @@ -971,6 +974,7 @@ cgraph_function_versioning (struct cgrap cgraph_copy_node_for_versioning (old_version_node, new_decl, redirect_callers, bbs_to_copy); + gcc_assert (!old_version_node->ipa_transforms_to_apply.exists ()); /* Copy the OLD_VERSION_NODE function tree to the new version. */ tree_function_versioning (old_decl, new_decl, tree_map, false, args_to_skip, skip_return, bbs_to_copy, new_entry_block); Index: src/gcc/trans-mem.c =================================================================== --- src.orig/gcc/trans-mem.c +++ src/gcc/trans-mem.c @@ -4914,6 +4914,7 @@ ipa_tm_create_version (struct cgraph_nod if (DECL_ONE_ONLY (new_decl)) DECL_COMDAT_GROUP (new_decl) = tm_mangle (DECL_COMDAT_GROUP (old_decl)); + gcc_assert (!old_node->ipa_transforms_to_apply.exists ()); new_node = cgraph_copy_node_for_versioning (old_node, new_decl, vNULL, NULL); new_node->local.local = false; new_node->externally_visible = old_node->externally_visible; Index: src/gcc/tree-inline.c =================================================================== --- src.orig/gcc/tree-inline.c +++ src/gcc/tree-inline.c @@ -5323,18 +5323,6 @@ tree_function_versioning (tree old_decl, id.dst_node = new_version_node; id.src_cfun = DECL_STRUCT_FUNCTION (old_decl); id.blocks_to_copy = blocks_to_copy; - if (id.src_node->ipa_transforms_to_apply.exists ()) - { - vec old_transforms_to_apply - = id.dst_node->ipa_transforms_to_apply; - unsigned int i; - - id.dst_node->ipa_transforms_to_apply - = id.src_node->ipa_transforms_to_apply.copy (); - for (i = 0; i < old_transforms_to_apply.length (); i++) - id.dst_node->ipa_transforms_to_apply.safe_push (old_transforms_to_apply[i]); - old_transforms_to_apply.release (); - } id.copy_decl = copy_decl_no_change; id.transform_call_graph_edges