From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BD02E3858D37; Mon, 13 Feb 2023 09:34:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD02E3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676280890; bh=u+3A1XWMzs4DVvYAqtBnnQTDLq7Ihx4E9X5HkuAWyLc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LAMIb4S8pkvav9UrMLS6xHhpwbDf+NLhzMpskezr4uhSsGa6wcux5VagnSOzGjSWh Y6ZF8UiwXohmOxeg8dT7de1CCqhUskSryvDN9hHmc9h0dTQM3tFx6y036u9JHyz3q7 sUaiQXtU9XipT+NBNdBon6kaO4vRofB04f8SY1EY= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108691] [13 Regression] ICE with function ptr and setjmp/returns twice at -O1 Date: Mon, 13 Feb 2023 09:34:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: ice-on-valid-code, needs-bisection X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 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=3D108691 --- Comment #6 from Richard Biener --- The reason is that gimple_call_flags returns a different answer from the indirect function call vs. the direct function call after propagating of the &setjmp constant. First of all 'returns_twice' is an attribute that cannot be set on a function type: int __attribute__((returns_twice)) (*foo) (void); > gcc-12 -S t.c -Wall t.c:1:1: warning: 'returns_twice' attribute ignored [-Wattributes] 1 | int __attribute__((returns_twice)) (*foo) (void); | ^~~ so one cannot have an indirect call annotated. But even then we for example treat indirect missing 'noreturn' conservatively, not requiring it to end a BB and only enforce that in the fixup-CFG pass. Now, for return_twice we could similarly check gimple_call_ctrl_altering. That still leaves us with missing abnormal edges - David, was this reduced from an actual program? When fixing up DCE to not set cfun->calls_setjmp it will eventually be set late in emit_call_1 via if (ecf_flags & ECF_RETURNS_TWICE) { add_reg_note (call_insn, REG_SETJMP, const0_rtx); cfun->calls_setjmp =3D 1; } a "fix" here would be to _check_ for cfun->calls_setjmp instead of setting = it (or assert it is set). The control-altering flag has no representation on GENERIC, and we're still expanding calls via intermediate GENERIC ...=