From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 42256 invoked by alias); 30 Dec 2017 09:54:37 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 42245 invoked by uid 89); 30 Dec 2017 09:54:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-16.9 required=5.0 tests=BAYES_00,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:2289 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 30 Dec 2017 09:54:35 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F1FF680F75; Sat, 30 Dec 2017 09:54:33 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-90.ams2.redhat.com [10.36.116.90]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8600A5D6A3; Sat, 30 Dec 2017 09:54:33 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id vBU9sOcB004243; Sat, 30 Dec 2017 10:54:30 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id vBU9sHJq004242; Sat, 30 Dec 2017 10:54:17 +0100 Date: Sat, 30 Dec 2017 09:54:00 -0000 From: Jakub Jelinek To: Tom de Vries Cc: GCC Patches Subject: Re: [libgomp, openacc, openmp, PR83046] Prune removed funcs from offload table Message-ID: <20171230095417.GL1833@tucnak> Reply-To: Jakub Jelinek References: <048f596a-75d5-c897-2630-d6230640cf40@mentor.com> <20171228160657.GJ1833@tucnak> <20171228161438.GK1833@tucnak> <76c90534-67c9-aadb-519d-172c3b42072c@mentor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <76c90534-67c9-aadb-519d-172c3b42072c@mentor.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg01604.txt.bz2 On Fri, Dec 29, 2017 at 02:07:49PM +0100, Tom de Vries wrote: > --- a/gcc/lto-streamer-out.c > +++ b/gcc/lto-streamer-out.c > @@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see > #include "builtins.h" > #include "gomp-constants.h" > #include "debug.h" > +#include "omp-offload.h" > > > static void lto_write_tree (struct output_block*, tree, bool); > @@ -2355,6 +2356,31 @@ lto_output (void) > int i, n_nodes; > lto_symtab_encoder_t encoder = lto_get_out_decl_state ()->symtab_node_encoder; > > + bool truncated_p = false; I don't think you need this var. > + unsigned int write_index = 0; > + for (unsigned read_index = 0; read_index < vec_safe_length (offload_funcs); > + read_index++) > + { > + tree fn_decl = (*offload_funcs)[read_index]; > + bool remove_p = cgraph_node::get (fn_decl) == NULL; > + if (remove_p) > + { > + truncated_p = true; > + continue; > + } > + > + if (write_index != read_index) > + (*offload_funcs)[write_index] = (*offload_funcs)[read_index]; > + > + write_index++; > + } > + if (truncated_p) > + offload_funcs->truncate (write_index); Either you truncate unconditionally, truncate is extremely cheap operation, or if you really wanted to guard it, you could just do if (read_index != write_index) > + > + if (!flag_lto) > + for (unsigned i = 0; i < vec_safe_length (offload_funcs); i++) > + DECL_PRESERVE_P ((*offload_funcs)[i]) = 1; Can you please do this inside of the above loop, you have fn_decl already there, just do it after the if (remove_p) continue; And, I think you can do it unconditionally at that point, or, can you use in_lto_p instead of flag_lto? flag_lto is set even during the -flto compilation of the sources before LTO is streamed, there is no need to pessimize that code, we can still remove it, we just can't remove anything after we've streamed LTO bytecode (for either the host or offloading targets). > @@ -7058,7 +7058,11 @@ expand_omp_target (struct omp_region *region) > > /* Add the new function to the offload table. */ > if (ENABLE_OFFLOADING) > - vec_safe_push (offload_funcs, child_fn); > + { > + if (flag_lto) > + DECL_PRESERVE_P (child_fn) = 1; And use if (in_lto_p) here too. Ok for trunk with those changes. Jakub