public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/106816] New: noreturn/pure attributes are not set correctly on multiversioned functions
@ 2022-09-02 15:34 gcc.gnu at vvalter dot com
  2022-09-02 17:26 ` [Bug ipa/106816] " hjl.tools at gmail dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: gcc.gnu at vvalter dot com @ 2022-09-02 15:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106816

            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 with
-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 after
the call instruction. Similar problems happen if the function is marked pure.
I reproduced this on 11.2.0 and 12.2, but this most likely affects all gcc
versions.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-05-21  9:12 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 15:34 [Bug ipa/106816] New: noreturn/pure attributes are not set correctly on multiversioned functions gcc.gnu at vvalter dot com
2022-09-02 17:26 ` [Bug ipa/106816] " hjl.tools at gmail dot com
2022-09-02 17:55 ` gcc.gnu at vvalter dot com
2022-09-02 18:39 ` hjl.tools at gmail dot com
2022-09-02 19:48 ` gcc.gnu at vvalter dot com
2022-09-05 10:02 ` rguenth at gcc dot gnu.org
2022-09-14 13:58 ` marxin at gcc dot gnu.org
2022-09-14 13:59 ` marxin at gcc dot gnu.org
2022-12-28 14:50 ` marxin at gcc dot gnu.org
2023-01-03 10:27 ` jamborm at gcc dot gnu.org
2023-01-06 15:17 ` marxin at gcc dot gnu.org
2023-04-03  9:03 ` marxin at gcc dot gnu.org
2023-04-26  6:56 ` rguenth at gcc dot gnu.org
2023-07-27  9:23 ` rguenth at gcc dot gnu.org
2024-05-21  9:12 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).