From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 02E1A3858C3A; Thu, 1 Feb 2024 12:24:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 02E1A3858C3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706790241; bh=OHIMWXpKdsxiLVInlazNbwZRgwh8NWsXEz4hql8NrL8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UrW2U/Xs0o8miK+eocNL4rMfgPVC+IUEWnZKVZNF5DEwM550LF+Ji0r0zPL4C6AY0 5Qx75ag/yfb6GR6rrwk/vPlxfeY4HnssAb75E9MShfzUvRcXuX17w2AHOgLlFbmX5o 6xmWXkztXF5pKdif3p3C4dPg3nL1YYAfKhXqXhsQ= From: "lukas.graetz@tu-darmstadt.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/38534] gcc 4.2.1 and above: No need to save called-saved registers in 'noreturn' function Date: Thu, 01 Feb 2024 12:23:59 +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: 4.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lukas.graetz@tu-darmstadt.de 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=3D38534 --- Comment #25 from Lukas Gr=C3=A4tz --- (In reply to Jakub Jelinek from comment #19) > (In reply to H.J. Lu from comment #18) > > (In reply to Jakub Jelinek from comment #17) > > > E.g. shouldn't it at least be disabled for -O0 and -Og and shouldn't = we > >=20 > > We can disable this for -O0 and -Og. >=20 > I think we should go for that. >=20 This is independent from debugging, but I thought the patch was only meant = for -O3. Have you thought about the following situation: Compile with gcc -O1 (and --fno-exception is implicit): ---- library.c ---------------- void __attribute__((noreturn)) foo(void (*bar)(void)) { ... bar(); while (1); } --------------------- Compile with g++ (and -fexception is implicit): ---- app.c++ ---------------- #include extern void foo(void (*bar)(void)); extern void bar_throws_exception(void) throw (); int main() { ... try { foo(bar_throws_exception); } catch (const std::exception& e) { ... } } ---------------------- It is not hart to fill the ... to make it use some callee-saved registers (= e.g. with LOOP_BODY as in this issue report). And then the program would crash. One might argue that either the library.c is to blame for the missing -fexceptions? Or that the app.c++ is to blame because it should not call foo with an argument function that might throw an exception? I am unsure if the= C++ standard actually forbids calling C library functions with argument functio= ns that might throw an exception. So I think it would be safer to restrict the patch to -O3. But I really don= 't know much about this.=