From patchwork Tue Jan 21 15:37:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1226636 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-517909-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=XAZEmaX4; 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 482CNJ4pjMz9sRk for ; Wed, 22 Jan 2020 02:37:52 +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=Veji3O6CVA8dlxHXIuE9D88lqZQsbof4mVe+IAd0qMQovv3ZLdZz3 iiPfVS+6qBJ3or6jndirTQp8Bq5FIio112E1xrd52dt4si2e3fg8cusjViVRtFF+ MtMtyiKWQQUElizAkdQGPychqgnKE1oPnuOQ5Jb0CG48KaFqSs8XEo= 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=Unq6fHZ9fwV0qw4Sx3bfj430FWM=; b=XAZEmaX4j81ikleZDURg icIhrB8qDkKop+g7r22d1mnztz219bQXvVPHrn2QbxSujFRvP6v1R3CNU0rVP37n e2JobOE7mxY00jXBSaNrJq072zLUiFixO9M8K+ZsevY6GoMyUcP4u90mSqaisFa9 7IXP8KfJStZ+xrDYBPXhIXQ= Received: (qmail 15488 invoked by alias); 21 Jan 2020 15:37: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 11801 invoked by uid 89); 21 Jan 2020 15:37:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1892, site X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Jan 2020 15:37:33 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 30CB828076C; Tue, 21 Jan 2020 16:37:31 +0100 (CET) Date: Tue, 21 Jan 2020 16:37:31 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix updating of call_stmt_site_hash Message-ID: <20200121153731.GJ51597@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Hi, this patch fixes ICE causes by call stmt site hash going out of sync. For speculative edges it is assumed to contain a direct call so if we are removing it hashtable needs to be updated. I realize that the code is ugly but I will leave cleanup for next stage1. Bootstrapped/regtested x86_64-linux. This patch makes it possible to build Firefox again. PR lto/93318 * cgraph.c (cgraph_edge::resolve_speculation, cgraph_edge::redirect_call_stmt_to_callee): Fix update of call_stmt_site_hash. diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 187f6ed30ba..f7ebcc917d1 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1248,7 +1248,22 @@ cgraph_edge::resolve_speculation (cgraph_edge *edge, tree callee_decl) else e2->callee->remove_symbol_and_inline_clones (); if (edge->caller->call_site_hash) - cgraph_update_edge_in_call_site_hash (edge); + { + /* We always maintain direct edge in the call site hash, if one + exists. */ + if (!edge->num_speculative_call_targets_p ()) + cgraph_update_edge_in_call_site_hash (edge); + else + { + cgraph_edge *e; + for (e = edge->caller->callees; + e->call_stmt != edge->call_stmt + || e->lto_stmt_uid != edge->lto_stmt_uid; + e = e->next_callee) + ; + cgraph_update_edge_in_call_site_hash (e); + } + } return edge; } @@ -1414,7 +1429,20 @@ cgraph_edge::redirect_call_stmt_to_callee (cgraph_edge *e) /* Indirect edges are not both in the call site hash. get it updated. */ if (e->caller->call_site_hash) - cgraph_update_edge_in_call_site_hash (e2); + { + if (!e2->num_speculative_call_targets_p ()) + cgraph_update_edge_in_call_site_hash (e2); + else + { + cgraph_edge *e; + for (e = e2->caller->callees; + e->call_stmt != e2->call_stmt + || e->lto_stmt_uid != e2->lto_stmt_uid; + e = e->next_callee) + ; + cgraph_update_edge_in_call_site_hash (e); + } + } pop_cfun (); /* Continue redirecting E to proper target. */ }