From patchwork Sat Dec 14 09:11:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1209706 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515986-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="nUrm4p3H"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="LpnNICkG"; dkim-atps=neutral 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 47ZhcV5slHz9sPL for ; Sat, 14 Dec 2019 20:11:53 +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:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=lsm bJ4gpvlcHHuMYKspkuOedAYDmxEVED+mullyu9JoZ//hTNIhlF1nxxFeDs8gGioD 9tmsa66jQwPm4rlyDTLs9x0TnNIAICnzsnMJEA6mv9PPCtW7E/BngtCkxhoh+asM 0nS+hzLIotM7HyGDPGDJ5DXA5Z6Y1yTGwycvpOfA= 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:reply-to:mime-version :content-type:content-transfer-encoding; s=default; bh=mznxlxDRK MqvmB2tNhDv5/i+zyQ=; b=nUrm4p3HYyY/m0lzOT0Wju5k4GQnSg99OCTMq3WfR XovrTa0Bl4U51KOv2njjHF4p2tRSJhe6PGRiH26WIILobgQRq4K7ovaLtoPjVmuk qhW0qJRs8VUSCH6wxjA/h8X47SzSYLCKQEtQfVtUUcLp+M+bXtOt/77waoqwb6Gk MI= Received: (qmail 61331 invoked by alias); 14 Dec 2019 09:11:45 -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 61323 invoked by uid 89); 14 Dec 2019 09:11:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=IRC, irc, walking X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 14 Dec 2019 09:11:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576314702; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1wffHPwwcO8qc3ATEHO/BC3N2LQ8Dp0isJJa46WmEf8=; b=LpnNICkGPYDo3mBd0hq1jv39FZLvsqk58js4At6N7DRoCKfumrtd4v/o1n47RWU206ppP6 htUx5xN3JeGumn/ren1XO3oeWaGgWsf/EOjXfPCQ/POUqTYcmcufPR8sQ4pUNDQPAsUjV1 XKBg1X7mo0oyMoR3Oecxtpj5/TS+Kow= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-357-KqseCO_pM1evfB0hAcTFFA-1; Sat, 14 Dec 2019 04:11:39 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 06AE01854321; Sat, 14 Dec 2019 09:11:38 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-59.ams2.redhat.com [10.36.117.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9140610016DA; Sat, 14 Dec 2019 09:11:37 +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 xBE9BYC2024420; Sat, 14 Dec 2019 10:11:35 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id xBE9BXUq024419; Sat, 14 Dec 2019 10:11:33 +0100 Date: Sat, 14 Dec 2019 10:11:33 +0100 From: Jakub Jelinek To: Jan Hubicka , Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix ipa_fn_summary_write for offloading LTO streaming (PR ipa/92357) Message-ID: <20191214091132.GT10088@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 Content-Disposition: inline X-IsSubscribed: yes Hi! As discussed on IRC and in the PR, we get an ICE during inline_read_section in the offloading lto1, because the size of streamed out and expected to be streamed in data doesn't match. This happens on the testcase from the PR where for (edge = cnode->callees; edge; edge = edge->next_callee) write_ipa_call_summary (ob, edge); writes summaries for 2 edges and for (e = node->callees; e; e = e->next_callee) read_ipa_call_summary (&ib, e, info != NULL); has NULL node->callees and doesn't thus stream in anything. That is because for (int i = 0; i < lto_symtab_encoder_size (encoder); i++) { node = dyn_cast (lto_symtab_encoder_deref (encoder, i)); if (node && ((node->thunk.thunk_p && !node->inlined_to) || lto_symtab_encoder_in_partition_p (encoder, node))) { output_outgoing_cgraph_edges (node->callees, ob, encoder); output_outgoing_cgraph_edges (node->indirect_calls, ob, encoder); } } didn't stream the callees out, as lto_symtab_encoder_in_partition_p (encoder, node) is false. All the other IPA writers that write function summaries only handle functions that pass this predicate, using the lsei_*_function_in_partition iterators, but ipa_fn_summary_write streams all. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, regtested on x86_64-linux with nvptx-none offloading, ok for trunk? Note, there is another issue unrelated to this that still needs fixing. 2019-12-14 Jakub Jelinek PR ipa/92357 * ipa-fnsummary.c (ipa_fn_summary_write): Use lto_symtab_encoder_iterator with lsei_start_function_in_partition and lsei_next_function_in_partition instead of walking all cgraph nodes in encoder. Jakub --- gcc/ipa-fnsummary.c.jj 2019-12-05 14:02:20.559570378 +0100 +++ gcc/ipa-fnsummary.c 2019-12-13 18:01:08.344828332 +0100 @@ -4364,24 +4364,24 @@ static void ipa_fn_summary_write (void) { struct output_block *ob = create_output_block (LTO_section_ipa_fn_summary); + lto_symtab_encoder_iterator lsei; lto_symtab_encoder_t encoder = ob->decl_state->symtab_node_encoder; unsigned int count = 0; - int i; - for (i = 0; i < lto_symtab_encoder_size (encoder); i++) + for (lsei = lsei_start_function_in_partition (encoder); !lsei_end_p (lsei); + lsei_next_function_in_partition (&lsei)) { - symtab_node *snode = lto_symtab_encoder_deref (encoder, i); - cgraph_node *cnode = dyn_cast (snode); - if (cnode && cnode->definition && !cnode->alias) + cgraph_node *cnode = lsei_cgraph_node (lsei); + if (cnode->definition && !cnode->alias) count++; } streamer_write_uhwi (ob, count); - for (i = 0; i < lto_symtab_encoder_size (encoder); i++) + for (lsei = lsei_start_function_in_partition (encoder); !lsei_end_p (lsei); + lsei_next_function_in_partition (&lsei)) { - symtab_node *snode = lto_symtab_encoder_deref (encoder, i); - cgraph_node *cnode = dyn_cast (snode); - if (cnode && cnode->definition && !cnode->alias) + cgraph_node *cnode = lsei_cgraph_node (lsei); + if (cnode->definition && !cnode->alias) { class ipa_fn_summary *info = ipa_fn_summaries->get (cnode); class ipa_size_summary *size_info = ipa_size_summaries->get (cnode);