From patchwork Sat Dec 12 14:44:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 556058 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 87B49140B8C for ; Sun, 13 Dec 2015 01:44:50 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=yFL1GdxX; 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=S7fgqZiD9qTJ527le ayN3+50RgacDYJ5nB+hkstrKjdy9x3TKLOd1G/27Xj+H/FEHfqq2emYkydAOuODK RCHok9Kxb8dLly4O1iLLYkv2ZpbSIwlpRCZUv6OQPBog/D6ppKn1AYj22XNa3dUb mTqdWsNB6VBLNVoIfN2TzEsgIg= 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=DkaybHNhkKk/0JqkLJ+BvOc Q2rg=; b=yFL1GdxXmjYFj5kNer62SHJnIYcG3iIuPOvPg4PbELIhiQfrjr9tIGS vVpkI6cJb+tGFrzL/xRzSGvgWzs9aycZGPsxyyYmtfZCiGPfLV9ke0XuDbChHSRz rEYX1nA+WSvxbFfuekwmDy+Zt7XYWqFprJJtiIIiaJCwqd7dHNeY= Received: (qmail 24529 invoked by alias); 12 Dec 2015 14:44:43 -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 24514 invoked by uid 89); 12 Dec 2015 14:44:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qg0-f52.google.com Received: from mail-qg0-f52.google.com (HELO mail-qg0-f52.google.com) (209.85.192.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sat, 12 Dec 2015 14:44:42 +0000 Received: by qgz52 with SMTP id 52so31879573qgz.1 for ; Sat, 12 Dec 2015 06:44:39 -0800 (PST) X-Received: by 10.140.165.16 with SMTP id l16mr23656330qhl.101.1449931479824; Sat, 12 Dec 2015 06:44:39 -0800 (PST) Received: from ?IPv6:2601:181:c000:c497:a2a8:cdff:fe3e:b48? ([2601:181:c000:c497:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id u143sm10329347qka.35.2015.12.12.06.44.38 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 12 Dec 2015 06:44:39 -0800 (PST) Subject: Re: update_vtable_references segfault To: Jan Hubicka References: <566B1036.7010502@acm.org> <20151211181505.GB27013@kam.mff.cuni.cz> Cc: GCC Patches From: Nathan Sidwell Message-ID: <566C32D6.90903@acm.org> Date: Sat, 12 Dec 2015 09:44:38 -0500 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: <20151211181505.GB27013@kam.mff.cuni.cz> On 12/11/15 13:15, Jan Hubicka wrote: >> Jan, >> b) augment can_replace_by_local_alias_in_vtable to check whether >> aliases can be created? > > I think this is best: can_replace_by_local_alias_in_vtable exists to prevent the > body walk in cases we are not going to create the alias. This is because in LTO > we may need to stream in the constructor from the object file that is not copletely > free and thus it is better to not touch it unless necessary. I went with augmenting can_replace_by_local_alias, which can_replace_by_local_alias_in_vtable calls. I also noticed that both should be static, which I suspect will encourage the inliner to go inline them and then determine a bunch of code is unreachable. tested on x86-linux and ptx-none. ok? nathan 2015-12-12 Nathan Sidwell * ipa-visibility.c (can_replace_by_local_alias): Make static, check ASM_OUTPUT_DEF. (can_replace_by_local_alias_in_vtable): Make static. (function_and_variable_visibility): Reformat overlong comment. Index: ipa-visibility.c =================================================================== --- ipa-visibility.c (revision 231571) +++ ipa-visibility.c (working copy) @@ -329,9 +329,13 @@ varpool_node::externally_visible_p (void Local aliases save dynamic linking overhead and enable more optimizations. */ -bool +static bool can_replace_by_local_alias (symtab_node *node) { +#ifndef ASM_OUTPUT_DEF + /* If aliases aren't supported, we can't do replacement. */ + return false; +#endif /* Weakrefs have a reason to be non-local. Be sure we do not replace them. */ while (node->transparent_alias && node->definition && !node->weakref) @@ -344,11 +348,11 @@ can_replace_by_local_alias (symtab_node && !node->can_be_discarded_p ()); } -/* Return true if we can replace refernece to NODE by local alias +/* Return true if we can replace reference to NODE by local alias within a virtual table. Generally we can replace function pointers and virtual table pointers. */ -bool +static bool can_replace_by_local_alias_in_vtable (symtab_node *node) { if (is_a (node) @@ -592,10 +596,11 @@ function_and_variable_visibility (bool w if (!node->local.local) node->local.local |= node->local_p (); - /* If we know that function can not be overwritten by a different semantics - and moreover its section can not be discarded, replace all direct calls - by calls to an noninterposable alias. This make dynamic linking - cheaper and enable more optimization. + /* If we know that function can not be overwritten by a + different semantics and moreover its section can not be + discarded, replace all direct calls by calls to an + noninterposable alias. This make dynamic linking cheaper and + enable more optimization. TODO: We can also update virtual tables. */ if (node->callers