From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2A70E3858C54; Fri, 2 Sep 2022 15:34:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A70E3858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662132884; bh=uKO4dqk0fxpZNMzid1BxRGlNMOTdq2RSEDrTSU5V6Qo=; h=From:To:Subject:Date:From; b=ir6AfSb5dBgNMu+6i1M5/VVGBNy/CQG9NjUXoltspRNhnyAmU/OMFrYKH4XKnRNnJ cXkXztZ7K2AZ/tyEyhMx8lvULcVCz1Q1hnR9BW7yynE6CMzO4BFGtr63skqZeUGGjm QBiuS9jH34slY1l527m267oIeQsnFLe0YR6ciExg= From: "gcc.gnu at vvalter dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/106816] New: noreturn/pure attributes are not set correctly on multiversioned functions Date: Fri, 02 Sep 2022 15:34:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gcc.gnu at vvalter dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: 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=3D106816 Bug ID: 106816 Summary: noreturn/pure attributes are not set correctly on multiversioned functions Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: gcc.gnu at vvalter dot com CC: marxin at gcc dot gnu.org Target Milestone: --- During the investigation of PR106627, Richard noted ( https://gcc.gnu.org/pipermail/gcc-patches/2022-September/600777.html ) that attributes like noreturn and pure on multiversioned functions are lost when= the function declaration is replaced by the dispatcher declaration in the same = way that the TREE_NOTHROW attribute got lost, which was fixed in PR106627. Example: __attribute__((noreturn,target("default"))) void f() { for (;;) {} } __attribute__((noreturn,target("sse4.2,bmi"))) void f() { for (;;) {} } int main() { f(); return 1; } Gcc should create no code after the call to f(), but the assembly output wi= th -O3 looks like the following: call _Z5_Z1fvv@PLT movl $1, %eax addq $8, %rsp .cfi_def_cfa_offset 8 ret For a non-multiversioned function, no assembly instructions are generated a= fter the call instruction. Similar problems happen if the function is marked pur= e. I reproduced this on 11.2.0 and 12.2, but this most likely affects all gcc versions.=