llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Paweł Bylica (chfast) <details> <summary>Changes</summary> A musttail call to a noreturn function (`__attribute__((noreturn))`, `_Noreturn`, `exit()`, `longjmp()`, ...) gets `unreachable` after it instead of `ret`, which fails the verifier with "musttail call must precede a ret". Release builds skip the verifier, so -O2 crashes with "failed to perform tail call elimination on a call site marked musttail" and -O0 silently emits a regular call. Sema only rejects `[[noreturn]]` callees (#<!-- -->77727), so all other spellings get through. Implicit musttail calls produce the same invalid IR: `swiftasynccall`, and the `-fptrauth-calls` thunk for a pointer to a noreturn virtual member function. The latter crashes even at -O0, without any `musttail` in the source. The noreturn path in `EmitCall` runs before the musttail one. This patch skips it for musttail calls, so they get a `ret` like any other musttail call. As a side effect, the musttail checks there (e.g. the noexcept mismatch error) now apply to noreturn callees too. This matches GCC, which accepts musttail calls to noreturn functions, `[[noreturn]]` ones included: https://godbolt.org/z/q8ajhMh15 With CodeGen handling it, the Sema error for `[[noreturn]]` callees is no longer needed. I'll lift it in a follow-up PR. Inspired by rnk's comment in #<!-- -->191198 asking whether the thunk code emitting a `ret` after the musttail call is dead: https://github.com/llvm/llvm-project/pull/191198#discussion_r3414988237. Only noreturn callees reach it. Fixes #<!-- -->60162. Fixes #<!-- -->120088. Fixes #<!-- -->120637. --- Full diff: https://github.com/llvm/llvm-project/pull/234580.diff 4 Files Affected: - (modified) clang/docs/ReleaseNotes.md (+5) - (modified) clang/lib/CodeGen/CGCall.cpp (+3-2) - (added) clang/test/CodeGen/musttail-noreturn.c (+29) - (modified) clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp (+14) ``````````diff The server is unavailable at this time. Please wait a few minutes before you try again. `````````` </details> https://github.com/llvm/llvm-project/pull/234580 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
