From patchwork Wed Oct 31 13:11:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 991392 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-488730-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Kji67wt2"; 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 42lTHw29mBz9s1c for ; Thu, 1 Nov 2018 00:11:38 +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:mime-version:content-type; q=dns; s=default; b=qopE3SVWPRzSlUU/gYC1RpUrTk6Q6r3nV6oJ1KleHAYvehzKeF k2HLBdVlzSK4PjDGyumpccNZ4FTejfWv0NqoCFV1qwWXzL9SN0QW4EKT10pYOYgD o27f7Kgf7EoDcsnFrTtXXFr1GGpdeqSfXLmE5ssS4sDrzDcQII9GHGHRs= 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=uoC0pBtvK7n7qD8TtJMiu4rQhpw=; b=Kji67wt2/Kyffg1rL2YM KgVagLte3zsaXBXQWKIvzD5tApFjZ0Xb1B05FPKP3G67T5dovB5xtFGanbqQ59eI sIMK2pMA68DoawAqDn5ZztfjKMwIavF3sfLj9s4O8Dm09qTT6yAdNfr6JtielDyp Qb0edI4wYgO7CKb6RGKkk8w= Received: (qmail 90218 invoked by alias); 31 Oct 2018 13:11:31 -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 89102 invoked by uid 89); 31 Oct 2018 13:11:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=editor, refering X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 Oct 2018 13:11:29 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 11212ACF8; Wed, 31 Oct 2018 13:11:27 +0000 (UTC) Date: Wed, 31 Oct 2018 14:11:26 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: jason@redhat.com, Jan Hubicka Subject: [PATCH] Avoid useless lookup_external_ref calls with LTO Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Honza reports high CPU usage from lookup_external_ref at LTRANS time. This is likely because build_abbrev_table calls it on all DIEs rather than just type DIEs which we populate the ref table with. So we end up calling it for all the DIEs refering to early debug, possibly many distinct ones with the same die.symbol (but usually different die_offset). That will end up with loads of hashtable collisions. The following patch restricts the build_abbrev_table lookups to type DIEs. We might consider optimizing the refs to decrease the number of relocations the link editor has to process but I guess it's not worth it and the rest of the optimize_external_refs isn't prepared for the LTO case anyways. Bootstrapped and tested on x86_64-unknown-linux-gnu. Honza has yet to confirm the patch helps, once he does I plan to install it. Richard. 2018-10-31 Richard Biener * dwarf2out.c (build_abbrev_table): Guard lookup_external_ref call with is_type_die. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 30bbfee9052..8b478aa265f 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -9023,8 +9023,9 @@ build_abbrev_table (dw_die_ref die, external_ref_hash_type *extern_map) struct external_ref *ref_p; gcc_assert (AT_ref (a)->comdat_type_p || AT_ref (a)->die_id.die_symbol); - ref_p = lookup_external_ref (extern_map, c); - if (ref_p->stub && ref_p->stub != die) + if (is_type_die (c) + && (ref_p = lookup_external_ref (extern_map, c)) + && ref_p->stub && ref_p->stub != die) change_AT_die_ref (a, ref_p->stub); else /* We aren't changing this reference, so mark it external. */