From patchwork Thu Aug 1 14:55:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 1967713 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=embecosm.com header.i=@embecosm.com header.a=rsa-sha256 header.s=google header.b=QrqD4mM+; 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 4WZXD51p4wz1ybV for ; Fri, 2 Aug 2024 00:59:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 58C7C385DDE3 for ; Thu, 1 Aug 2024 14:58:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id BADCA385DDE4 for ; Thu, 1 Aug 2024 14:58:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BADCA385DDE4 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BADCA385DDE4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524305; cv=none; b=g58AEXjPlV3caPUL0wvdB3kEEw3MAXq5MJx3+eTLNElaFQ4k53S8eDCf7HOlMt2I6ZenYtwhQMoRKzVEdbIIMWnRxCfF+zVrtRKgXjQorodKvX5WrC26lrfW7/Y/9cGV6F2hCfxigshLTPLPuh3pwOkeyfuW+ojEu8QKHpmvUE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524305; c=relaxed/simple; bh=V6khoR7iZT/kw0a6tEwMY8GZ1p2Q7N+1DAoXRz1+LB0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=smyRFvy4SCcxIcsM9RQcfyvoKQQfcDj321ovNxn0riR4DDJGPa6TitkdXQbWi30fmMhp0N4mkdi/k8EgfmVWbTIjKr8c/r4SLgqdKzbRcuOrjywVRty7fLPJjd7XpEYT7MhUw0VH4X4ReZ8SdIE4DEF2M7+5miZrQxlFEaX647U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a7ab63a388bso525243966b.1 for ; Thu, 01 Aug 2024 07:58:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1722524301; x=1723129101; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=R/dwDNzzSsACpcoy747tPuCQqjzSR+d7jALAO288gAo=; b=QrqD4mM+Ha9LvbN9a1RSxO6M2dBrA9ta5ggTVEkwHPO4VW8/17kBBkLHn0g7rv1OLY jI1mRSBciPtJqqPVP41EnhgWBnVWZO/MH28i0sEo6712q/fG0VaMtBb4AQCAfFkvD/3k zmVHXyjoTyrNFBWWQP7lpfcYmMGpG4OvkuOtpppSREt9xp9r9Oewu1mFQz7GpEcRnr8Z OOGPklOBsjHgvg8XoEcCH1Wmw9Js35YejOu97YTELRSWhkoSuPxGWX432ZdjwX/da33A iHe7MAmIOqzg+QMI00I/8VL/yHTDQrEq7seK5/YZHayRf5V9JP02TYBRJeN6+yTPCKa0 /sIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722524301; x=1723129101; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=R/dwDNzzSsACpcoy747tPuCQqjzSR+d7jALAO288gAo=; b=UYOoJnlnv+eKMacpLJtqSeYS9F8fU7VGv0Srj4XQ2LNbMuu6E0WwvfQxQCDRgFqWyH K4m4688BViIifYfaFmqe3BqfA8pOJlMoQ2RZlemu2FH5qTrgpgJzji6WKOIkr50sPjz/ apL3QSubJnA3wVzmuRCy1sUV8sNKU3tiQR5w6KHZDJhUiqN3xSTg5ybHBjicxtuI5hWy cSKx+ofxBV3wB3fhO939P7d7bwjqdHccWsdi9B5XHBk6RaW6Eyglgkbrgv6awn4EENsh 1xFVh4b+UhylqoNa9Xm58InvNp4qldAwqI0AcrpySzQCexydidK6QAZXiay2FfG0II0I L5dw== X-Gm-Message-State: AOJu0YxHIKMhxhe09ShpYlKiSspKpOwssbJkTIlXFdxocaf3pyFHUvXa Zb5iCqW9enIdg0F3YAhOXiShYopW0YjCfVWS+gHcelURShA5ddKQnGxQ9iWWHPoueeCsC4TCruo v/QIk X-Google-Smtp-Source: AGHT+IFVXOTymmui7XHzJduyE2efYP45VbmPS6j6WAvaVI26JR9uUvVzknoDWzvY39LiHjmmmfW6jQ== X-Received: by 2002:a05:6402:114e:b0:5a1:5692:b5f9 with SMTP id 4fb4d7f45d1cf-5b7f56fd3dbmr402256a12.38.1722524300996; Thu, 01 Aug 2024 07:58:20 -0700 (PDT) Received: from platypus.lan ([2a04:cec2:9:dc84:3622:6733:ff49:ee91]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac63590592sm10252456a12.25.2024.08.01.07.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 07:58:20 -0700 (PDT) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Thomas Schwinge Subject: [PATCH 001/125] Rust: Make 'tree'-level 'MAIN_NAME_P' work Date: Thu, 1 Aug 2024 16:55:56 +0200 Message-ID: <20240801145809.366388-2-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Thomas Schwinge 'gcc/tree.h': #define main_identifier_node global_trees[TI_MAIN_IDENTIFIER] #define MAIN_NAME_P(NODE) \ (IDENTIFIER_NODE_CHECK (NODE) == main_identifier_node) ..., which is not initialized by default, but has to be set up by every front end individually. 'MAIN_NAME_P' enables certain code optimizations, but is especially also relevant for back ends that emit additional program entry setup code for 'main'. gcc/rust/ * backend/rust-compile-base.cc (HIRCompileBase::compile_function): For 'main', initialize 'main_identifier_node'. --- gcc/rust/backend/rust-compile-base.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc index 984492f6607..4d6f0275b00 100644 --- a/gcc/rust/backend/rust-compile-base.cc +++ b/gcc/rust/backend/rust-compile-base.cc @@ -657,6 +657,12 @@ HIRCompileBase::compile_function ( // we don't mangle the main fn since we haven't implemented the main shim bool is_main_fn = fn_name.compare ("main") == 0; + if (is_main_fn) + { + rust_assert (!main_identifier_node); + /* So that 'MAIN_NAME_P' works. */ + main_identifier_node = get_identifier (ir_symbol_name.c_str ()); + } std::string asm_name = fn_name; unsigned int flags = 0;