Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] __attribute__((__noreturn__)) miscompile #113747

Open
ZijunZhaoCCK opened this issue Oct 26, 2024 · 0 comments
Open

[clang] __attribute__((__noreturn__)) miscompile #113747

ZijunZhaoCCK opened this issue Oct 26, 2024 · 0 comments
Labels
clang Clang issues not falling into any other category

Comments

@ZijunZhaoCCK
Copy link
Contributor

__attribute__((__noreturn__)) is miscompiled upstream.
See https://godbolt.org/z/T6nMoa75G from Miguel Young and his comment.

When using the standard [[noreturn]] and _Noreturn in their respective languages, codegen is identical, and correct. The C codegen is obviously wrong and clearly confusing the hell out of LLVM, as evidenced by this instruction sequence:

    jne     .LBB1_1
    mov     rax, qword ptr [rip + baz@GOTPCREL]
    call    rax
.LBB1_1: mov rax, qword ptr [rip + foo@GOTPCREL] call rax

(Just do call foo@PLT?)

My recommendation is that upstream use _Noreturn, or noreturn + <stdnoreturn.h>. Clang is clearly able to get this right, but somehow left hand isn't talking to right hand in the unification algorithm.

(This really isn't a C v. C++ difference at all; both languages define their standard noreturn primitives identically.)
@ZijunZhaoCCK ZijunZhaoCCK added the clang Clang issues not falling into any other category label Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

No branches or pull requests

1 participant