From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E02A33858D3C; Wed, 6 Dec 2023 18:19:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E02A33858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701886785; bh=Y5KjKVvp9kNFSmvjA6h+gSS4ZEs0WBfFDWR9OSAjS5E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AKLU9Ip2cN/k22pphX3M9Wooc7NzN/0Qb0Cp9Crd8KOg2GBkhGsAUYLuQYOycYlpa ruxxf5cztEOf25pxx2CBECDxkX3qx24UWEPPRE3TeBs45Wg1yLc+QJVUrG61H486sA mT/NE6Y8HWagE0MtSQD8LPXgavHEyKNaW3gjVujg= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/112411] ICE: SIGSEGV with --param=min-nondebug-insn-uid=2147483647 on powerpc64le-unknown-linux-gnu Date: Wed, 06 Dec 2023 18:19:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112411 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |vmakarov at gcc dot gnu.org --- Comment #8 from Jakub Jelinek --- Note, on void foo (void) { } ./cc1 -quiet --param min-nondebug-insn-uid=3D0x2aaaa000 pr112411.c still works but is fairly slow (various passes index arrays by INSN_UID and= if the uids are huge, it takes a lot of memory and compile time to clear them). But ./cc1 -quiet --param min-nondebug-insn-uid=3D0x2aaaaaaa a.c cc1: out of memory allocating 18446744065119617112 bytes after a total of 1626112 bytes Seems lra does some vec handling by hand and uses an int variable for it: lra.cc (check_and_expand_insn_recog_data): lra_insn_recog_data_len =3D index * 3 / 2 + 1; Shall we change lra_insn_recog_data_len to size_t (and tweak comparisons to avoid signed vs. unsigned compares)? Or at least adjust the above such that the computation is say done in unsig= ned HOST_WIDE_INT and use INT_MAX for lra_insn_recog_data_len on overflow rather than negative value (including UB at compile time)? With the following patch it compiles even with ./cc1 -quiet --param min-nondebug-insn-uid=3D0x40000000 a.c but my 32GB RAM + 24GB swap was almost full with that. --- gcc/params.opt.jj 2023-11-02 07:49:18.010852541 +0100 +++ gcc/params.opt 2023-12-06 18:55:57.045420935 +0100 @@ -779,7 +779,7 @@ Common Joined UInteger Var(param_min_loo The minimum threshold for probability of semi-invariant condition statemen= t to trigger loop split. -param=3Dmin-nondebug-insn-uid=3D -Common Joined UInteger Var(param_min_nondebug_insn_uid) Param +Common Joined UInteger Var(param_min_nondebug_insn_uid) Param IntegerRange= (0, 1073741824) The minimum UID to be used for a nondebug insn. -param=3Dmin-size-for-stack-sharing=3D --- gcc/lra.cc.jj 2023-12-05 13:17:29.642260866 +0100 +++ gcc/lra.cc 2023-12-06 19:14:52.117499420 +0100 @@ -764,11 +764,13 @@ static void check_and_expand_insn_recog_data (int index) { int i, old; + HOST_WIDE_INT len; if (lra_insn_recog_data_len > index) return; old =3D lra_insn_recog_data_len; - lra_insn_recog_data_len =3D index * 3 / 2 + 1; + len =3D index * HOST_WIDE_INT_C (3) / 2 + 1; + lra_insn_recog_data_len =3D MIN (len, INT_MAX); lra_insn_recog_data =3D XRESIZEVEC (lra_insn_recog_data_t, lra_insn_recog_data, lra_insn_recog_data_len);=