diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-03-28 10:49:40 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-03-28 10:49:40 +0100 |
commit | e176456cfe5b1013bbfc24853265dfb13673011c (patch) | |
tree | 8dbf2c89df79cf795d93020a9881f01eae114212 /libcpp | |
parent | c95f5a0c0719ad5b23f605b4d8f8dd3689a0066b (diff) | |
download | gcc-e176456cfe5b1013bbfc24853265dfb13673011c.zip gcc-e176456cfe5b1013bbfc24853265dfb13673011c.tar.gz gcc-e176456cfe5b1013bbfc24853265dfb13673011c.tar.bz2 |
tailc: Handle musttail noreturn calls [PR119483]
The following (first) testcase is accepted by clang (if clang::musttail)
and rejected by gcc, because we discover the call is noreturn and then bail
out because we don't want noreturn tailcalls.
The general reason not to support noreturn tail calls is for cases like
abort where we want nicer backtrace, but if user asks explicitly to
musttail a call which either is explicitly noreturn or is implicitly
determined to be noreturn, I don't see a reason why we couldn't do that.
Both for tail calls and tail recursions.
An alternative would be to keep rejecting musttail to explicit noreturn,
but not actually implicitly mark anything as noreturn if it has any musttail
calls. But it is unclear how we could do that, such marking is I think done
typically before IPA and e.g. for LTO we won't know whether some other TU
could have musttail calls to it. And keeping around both explicit and
implicit noreturn bits would be ugly. Well, I guess we could differentiate
between presence of noreturn/_Noreturn attributes and just ECF_NORETURN
without those, but then tailc would still need to support it, just error out
if it was explicit.
2025-03-28 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/119483
* tree-tailcall.cc (find_tail_calls): Handle noreturn musttail
calls.
(eliminate_tail_call): Likewise.
(tree_optimize_tail_calls_1): If cfun->has_musttail and
diag_musttail, handle also basic blocks with no successors
with noreturn musttail calls.
* calls.cc (can_implement_as_sibling_call_p): Allow ECF_NORETURN
calls if they are musttail calls.
* c-c++-common/pr119483-1.c: New test.
* c-c++-common/pr119483-2.c: New test.
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions