From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7F036385E839; Fri, 15 Mar 2024 23:29:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F036385E839 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710545365; bh=/xt76tOqkS221rZ1K6twfAn3d54XwshtU+rZImEAlK0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xBRFhL1KpV4bSimRExb1wpY5+GwpkUZynK4h1HVaNiH28S8M1nfMFnFw/yE81PsRr 1dtuxLl8KS0SFyAGiO1zgVjjBiSZnPtsy2cVuByhEQJ9vqGK9zVviIcxrDCN4OKAtZ EQisfWpWrM4bFxu7ig/MxuAl8dsY0d9goi6+ubRo= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/110079] [11/12/13 Regression] ICE with -freorder-blocks-and-partition and inline-asm goto Date: Fri, 15 Mar 2024 23:29:21 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: ice-on-valid-code, inline-asm X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.5 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=3D110079 --- Comment #7 from GCC Commits --- The releases/gcc-13 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:6b69cbe2c85f0b8f4a5a6b23e257d69275bea182 commit r13-8448-g6b69cbe2c85f0b8f4a5a6b23e257d69275bea182 Author: Jakub Jelinek Date: Thu Mar 7 10:02:49 2024 +0100 bb-reorder: Fix -freorder-blocks-and-partition ICEs on aarch64 with asm goto [PR110079] The following testcase ICEs, because fix_crossing_unconditional_branches thinks that asm goto is an unconditional jump and removes it, replacing= it with unconditional jump to one of the labels. This doesn't happen on x86 because the function in question isn't invok= ed there at all: /* If the architecture does not have unconditional branches that can span all of memory, convert crossing unconditional branches into indirect jumps. Since adding an indirect jump also adds a new register usage, update the register usage information as well. */ if (!HAS_LONG_UNCOND_BRANCH) fix_crossing_unconditional_branches (); I think for the asm goto case, for the non-fallthru edge if any we shou= ld handle it like any other fallthru (and fix_crossing_unconditional_branc= hes doesn't really deal with those, it only looks at explicit branches at t= he end of bbs and we are in cfglayout mode at that point) and for the labe= ls we just pass the labels as immediates to the assembly and it is up to t= he user to figure out how to store them/branch to them or whatever they wa= nt to do. So, the following patch fixes this by not treating asm goto as a simple unconditional jump. I really think that on the !HAS_LONG_UNCOND_BRANCH targets we have a bug somewhere else, where outofcfglayout or whatever should actually create those indirect jumps on the crossing edges instead of adding normal unconditional jumps, I see e.g. in __attribute__((cold)) int bar (char *); __attribute__((hot)) int baz (char *); void qux (int x) { if (__builtin_expect (!x, 1)) goto l1; bar (""); goto l1; l1: baz (""); } void corge (int x) { if (__builtin_expect (!x, 0)) goto l1; baz (""); l= 2: return; l1: bar (""); goto l2; } with -O2 -freorder-blocks-and-partition on aarch64 before/after this pa= tch just b .L? jumps which I believe are +-32MB, so if .text is larger than 32MB, it could fail to link, but this patch doesn't address that. 2024-03-07 Jakub Jelinek PR rtl-optimization/110079 * bb-reorder.cc (fix_crossing_unconditional_branches): Don't ad= just asm goto. * gcc.dg/pr110079.c: New test. (cherry picked from commit b209d905f5ce1fa9d76ce634fd54245ff340960b)=