From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id E878C3858401; Mon, 21 Nov 2022 09:03:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E878C3858401 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.96,180,1665475200"; d="scan'208";a="87695884" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 21 Nov 2022 01:03:21 -0800 IronPort-SDR: jTpbUqH69HudsaZDQeaVhymxs40rGgSOvTw7mETt0kNCXZwMn+irBRhUPtfNoLn2BOqyiCtZv9 uhpjfwpffmGUNWAuB8B7SeZ3+N8har4trMRK9l8tmjcZWz1NZcVjk4aMb9dteuJ5skijPZMeDr o4H/v7ihQJT1xHnjtU+3tFQPyEo3n3omqyW/KL4WW2eOmbelcXDZkc48BwhceDJF+Qjno5VREX 8auu/wa3+R+5Rpc1clcPqQuYX8sSO7ze7Seu+/z7rQbmdAST0mroCeoW6bZp6pvvO5FE9c7MIj u3A= From: Thomas Schwinge To: Richard Biener , CC: , Subject: Re: [PATCH Rust front-end v3 38/46] gccrs: Add HIR to GCC GENERIC lowering entry point In-Reply-To: References: <20221026081811.602573-1-arthur.cohen@embecosm.com> <20221026081811.602573-39-arthur.cohen@embecosm.com> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/27.1 (x86_64-pc-linux-gnu) Date: Mon, 21 Nov 2022 10:03:15 +0100 Message-ID: <87fsecllws.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi! On 2022-11-09T14:53:44+0100, Richard Biener via Gcc-patches wrote: > On Wed, Oct 26, 2022 at 10:37 AM wrote: >> This patch [...] also contains a constant evaluator, ported >> over from the C++ frontend. Given that, and then: >> --- /dev/null >> +++ b/gcc/rust/backend/rust-constexpr.cc >> +struct constexpr_global_ctx >> +{ >> + HOST_WIDE_INT constexpr_ops_count; > > If this isn't a INTEGER_CST related value then please avoid HOST_WIDE_INT > and instead use uint64_t (or other more appropriate types). > >> + >> + constexpr_global_ctx () : constexpr_ops_count (0) {} >> +}; >> +[...] >> +static tree >> +constexpr_expression (const constexpr_ctx *ctx, tree t) >> +{ >> + [...] >> + // Avoid excessively long constexpr evaluations >> + if (++ctx->global->constexpr_ops_count >=3D constexpr_ops_limit) >> + { >> + rust_error_at ( >> + Location (loc), >> + "% evaluation operation count exceeds limit of " >> + "%wd (use %<-fconstexpr-ops-limit=3D%> to increase the limit)", >> + constexpr_ops_limit); >> + >> + return t; >> + } Arthur thus turned the 'HOST_WIDE_INT constexpr_ops_count' into an 'unsigned long', see "58e75f65e56d: Remove HOST_WIDE_INT struct member", but that results in GCC bootstrap failure: [...]/source-gcc/gcc/rust/backend/rust-constexpr.cc: In function =E2=80= =98tree_node* Rust::Compile::constexpr_expression(const constexpr_ctx*, tre= e)=E2=80=99: [...]/source-gcc/gcc/rust/backend/rust-constexpr.cc:99:42: error: compa= rison of integer expressions of different signedness: =E2=80=98long unsigne= d int=E2=80=99 and =E2=80=98long int=E2=80=99 [-Werror=3Dsign-compare] 99 | if (++ctx->global->constexpr_ops_count >=3D constexpr_ops_lim= it) See the original C++ code: gcc/cp/constexpr.cc: HOST_WIDE_INT constexpr_ops_count; gcc/c-family/c.opt-fconstexpr-ops-limit=3D gcc/c-family/c.opt:C++ ObjC++ Joined RejectNegative Host_Wide_Int Var(c= onstexpr_ops_limit) Init(33554432) gcc/c-family/c.opt--fconstexpr-ops-limit=3D Specify maxim= um number of constexpr operations during a single constexpr evaluation. So I suggest change back the GCC/Rust 'constexpr_ops_count' to 'HOST_WIDE_INT' (submitted 'Revert #1661 "58e75f65e56d: Remove HOST_WIDE_INT struct member"'), and if anything needs to be changed, do thatt in GCC/C++ first, and then mirror that into GCC/Rust. Gr=C3=BC=C3=9Fe Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955