From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B4BC73858023; Fri, 8 Dec 2023 07:33:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4BC73858023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1702020788; bh=GwtiklVRVUS08QCfOxHTzrJlx9b7Wt/lbRTmt0JVf30=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lwJHOjmSpMYQQ0q52V7LFFcfnSliYCsG78g3XkWWG7IVw8xlAOTnCYh7HK8e7NYBb Jv8A2ieBpKPK+ssdevY+LiDPtlmqvxqhgMDooCotcm0MjpMdUBeNlzU/MiALfW6c65 Rdm4RndF4eqWgFySROHel/7JuXZAmnqQ5zJ2DfqU= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/112411] ICE: SIGSEGV with --param=min-nondebug-insn-uid=2147483647 on powerpc64le-unknown-linux-gnu Date: Fri, 08 Dec 2023 07:33:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit 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: 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 --- Comment #11 from GCC Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:39a1ab9c33b6067b1cc843408886e7ba709fbb62 commit r14-6302-g39a1ab9c33b6067b1cc843408886e7ba709fbb62 Author: Jakub Jelinek Date: Fri Dec 8 08:29:44 2023 +0100 Add IntegerRange for -param=3Dmin-nondebug-insn-uid=3D and fix vector g= rowing in LRA and vec [PR112411] As documented, --param min-nondebug-insn-uid=3D is very useful in debug= ging -fcompare-debug issues in RTL dumps, without it it is really hard to find differences. With it, DEBUG_INSNs generally use low INSN_UIDs (1+) and non-DEBUG_INSNs use INSN_UIDs from the parameter up. For good results, the parameter should be larger than the number of DEBUG_INSNs in all or at least problematic functions, so I typically use --param min-nondebug-insn-uid=3D10000 or --param min-nondebug-insn-uid=3D1000. The PR is about using --param min-nondebug-insn-uid=3D2147483647 or similar behavior can be achieved with that minus some epsilon, INSN_UIDs for the non-debug insns then wrap around and as they are sign= ed, all kinds of things break. Obviously, that can happen even without that option, but functions containing more than 2147483647 insns usually don= 't compile much earlier due to getting out of memory. As it is a debugging option, I'd prefer not to impose any drastically s= mall limits on it because if a function has a lot of DEBUG_INSNs, it is usef= ul to start still above them, otherwise the allocation of uids will DTRT even for DEBUG_INSNs but there will be then differences in non-DEBUG_IN= SN allocations. So, the following patch uses 0x40000000 limit, half the maximum amount = for DEBUG_INSNs and half for non-DEBUG_INSNs, it will still result in very unlikely overflows in real world. Note, using large min-nondebug-insn-uid is very expensive for compile t= ime memory and compile time, because DF as well as various RTL passes use arrays indexed by INSN_UIDs, e.g. LRA with sizeof (void *) elements, ditto df (df->insns). Now, in LRA I've ran into ICEs already with --param min-nondebug-insn-uid=3D0x2aaaaaaa on 64-bit host. It uses a custom vector management and wants to grow allocation 1.5x when growing, but all this computation is done in int, so already 0x2aaaaaab * 3 / 2 + 1 overflows to negative value. And unlike vec.cc growing which also uses unsigned int type for the above (and the + 1 is not there), it also doesn't make sure if there is an overflow that it allocates at least as much as needed, vec.cc does if ... else /* Grow slower when large. */ alloc =3D (alloc * 3 / 2); /* If this is still too small, set it to the right size. */ if (alloc < desired) alloc =3D desired; so even if there is overflow during the * 1.5 computation, but desired is still representable in the range of the alloced counter (31-bits in both vec.h and LRA), it doesn't grow exponentially but at least works for the current value. The patch now uses there lra_insn_recog_data_len =3D index * 3U / 2; if (lra_insn_recog_data_len <=3D index) lra_insn_recog_data_len =3D index + 1; basically do what vec.cc does. I thought we could do better for both vec.cc and LRA on 64-bit hosts even without growing the allocated counters, but now that I look at it again, perhaps we can't. The above overflows already with original alloc or lra_insn_recog_data_= len 0x55555556, where 0x5555555 * 3U / 2 is still 0x7fffffff and so representable in the 32-bit, but 0x55555556 * 3U / 2 is 1. I thought that we could use alloc * (size_t) 3 / 2 so that on 64-bit hosts it wouldn't overflow that quickly, but 0x55555556 * (size_t) 3 / 2 there is 0x80000001 which is still ok in unsigned, but given that vec.h then stores the counter into unsigned m_alloc:31; bit-field, it is too much. With the lra.cc change, one can actually compile simple function with -O0 on 64-bit host with --param min-nondebug-insn-uid=3D0x40000000 (i.e. the new limit), but already needed quite a big part of my 32GB RAM + 24GB swap. The patch adds a dg-skip-if for that case though, because such option is way too much for 32-bit hosts even at -O0 and empty function, and with -O3 on a longer function it is too much for average 64-bit host as well. Without the dg-skip-if I got on 64-bit host: cc1: out of memory allocating 571230784744 bytes after a total of 27729= 92 bytes and cc1: out of memory allocating 1388 bytes after a total of 2002944 bytes on 32-bit host. A test requiring more than 532GB of RAM on 64-bit hosts is just too much for our testsuite. 2023-12-08 Jakub Jelinek PR middle-end/112411 * params.opt (-param=3Dmin-nondebug-insn-uid=3D): Add IntegerRange(0, 1073741824). * lra.cc (check_and_expand_insn_recog_data): Use 3U rather than= 3 in * 3 / 2 computation and if the result is smaller or equal to index, use index + 1. * gcc.dg/params/blocksort-part.c: Add dg-skip-if for --param min-nondebug-insn-uid=3D1073741824.=