From patchwork Fri Jan 12 10:03:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1885954 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iczgacns; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TBHFL29LQz1yP3 for ; Fri, 12 Jan 2024 21:04:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D5AC9385841D for ; Fri, 12 Jan 2024 10:04:18 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 5D5E23858D3C for ; Fri, 12 Jan 2024 10:03:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D5E23858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5D5E23858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705053833; cv=none; b=Dm5k7sNtjELhDegFp5OVgjsHAwVb0kSR5QVDG/Yo/IJhJIK2cZqvQ2bq4kw2ie7AQAk8ok2MrGJk09wQ9tzhNQsnnsTLNThfrHaGLcuIv9f+qounpn7Ax/gXpEhqU6sjfm5ljTeA2pmPvEpZyApl/+of1eQOqpIsn99ICz8VTyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705053833; c=relaxed/simple; bh=xdis318HZT6JOlOe6ZUDkozLQxXFQ9zzuchQmArHWeA=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=j4ct2bCUJ0Bai7jGup7TDCFe3vUlXRzmglgtmEUUp7M0SZJW/RAaEB9tScetau5cbykK/DmlOsauLWu+OEvpJgdepsLJ2lDlHRIBRy0kstG1MuB9Z5Dp1lOXm+IrqDsFZTDtljPzKtwkAv6xzTqvt+RsTNMPL1VOiMbEyZ6ogP4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705053831; 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; bh=hyuejXyb9nJ2jVmnh2LOUqV/YpB8X9E9tb4CBpEBX7g=; b=iczgacns0GzzRKSnx7Syb4Bd89V10Xt4g/ByWvXNVO4ND30u0GBuFhA7puO8t08OinnYOx /qjsuRBitZfFlvF0SZnR13pFhqqW7/63L/0BEISuZSVwxRJnCOAjloO1sVZTeqh+0HK4y1 WjunN+4bpUm9519HrHv+gEkulYXjIuo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-596-qixQ6_caO8Sn2BsGBmzKAg-1; Fri, 12 Jan 2024 05:03:49 -0500 X-MC-Unique: qixQ6_caO8Sn2BsGBmzKAg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 733618A4403; Fri, 12 Jan 2024 10:03:49 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 33F37C08EE4; Fri, 12 Jan 2024 10:03:49 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 40CA3kRK3307396 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 12 Jan 2024 11:03:46 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 40CA3jw33307395; Fri, 12 Jan 2024 11:03:45 +0100 Date: Fri, 12 Jan 2024 11:03:44 +0100 From: Jakub Jelinek To: Jeff Law , Richard Biener Cc: gcc-patches@gcc.gnu.org, "Jose E. Marchesi" Subject: [PATCH] varasm: Fix up process_pending_assemble_externals [PR113182] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! John reported that on HP-UX we no longer emit needed external libcalls. The problem is that we didn't strip name encoding when looking up the identifiers in assemble_external_libcall and process_pending_assemble_externals, while assemble_name_resolve does that: const char *real_name = targetm.strip_name_encoding (name); tree id = maybe_get_identifier (real_name); if (id) { ... mark_referenced (id); The intention is that assemble_external_libcall ensures the IDENTIFIER exists for the external libcall, then for actually emitted calls assemble_name_resolve sees those IDENTIFIERS and sets TREE_SYMBOL_REFERENCED on them and finally process_pending_assemble_externals looks the IDENTIFIER up again and checks its TREE_SYMBOL_REFERENCED. But without the strip_name_encoding call, they can look up different identifiers and those are likely never used. In the PR, John was discussing whether get_identifier or maybe_get_identifier should be used, I believe in assemble_external_libcall we definitely want to use get_identifier, we need an IDENTIFIER allocated so that it can be actually tracked, in process_pending_assemble_externals it doesn't matter, the IDENTIFIER should be already created. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-01-12 John David Anglin Jakub Jelinek PR middle-end/113182 * varasm.cc (process_pending_assemble_externals, assemble_external_libcall): Use targetm.strip_name_encoding before calling get_identifier. Jakub --- gcc/varasm.cc.jj 2024-01-08 21:56:04.968516120 +0100 +++ gcc/varasm.cc 2024-01-11 18:44:19.171399167 +0100 @@ -2543,7 +2543,8 @@ process_pending_assemble_externals (void for (rtx list = pending_libcall_symbols; list; list = XEXP (list, 1)) { rtx symbol = XEXP (list, 0); - tree id = get_identifier (XSTR (symbol, 0)); + const char *name = targetm.strip_name_encoding (XSTR (symbol, 0)); + tree id = get_identifier (name); if (TREE_SYMBOL_REFERENCED (id)) targetm.asm_out.external_libcall (symbol); } @@ -2631,7 +2632,8 @@ assemble_external_libcall (rtx fun) reference to it will mark its tree node as referenced, via assemble_name_resolve. These are eventually emitted, if used, in process_pending_assemble_externals. */ - get_identifier (XSTR (fun, 0)); + const char *name = targetm.strip_name_encoding (XSTR (fun, 0)); + get_identifier (name); pending_libcall_symbols = gen_rtx_EXPR_LIST (VOIDmode, fun, pending_libcall_symbols); }