diff options
author | Hans <hans@hanshq.net> | 2024-05-15 15:29:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-15 15:29:08 +0200 |
commit | 3bb39690d729d85cd93c9dd6e750d82d6f367541 (patch) | |
tree | eadd50334423e3a140487aa550a4fba1089c7d32 /llvm/lib/Support/StringExtras.cpp | |
parent | b59760d83d10c27f22d77b7df24871500167c3e8 (diff) | |
download | llvm-3bb39690d729d85cd93c9dd6e750d82d6f367541.zip llvm-3bb39690d729d85cd93c9dd6e750d82d6f367541.tar.gz llvm-3bb39690d729d85cd93c9dd6e750d82d6f367541.tar.bz2 |
[coro] Lower `llvm.coro.await.suspend.handle` to resume with tail call (#89751)
The C++ standard requires that symmetric transfer from one coroutine to
another is performed via a tail call. Failure to do so is a miscompile
and often breaks programs by quickly overflowing the stack.
Until now, the coro split pass tried to ensure this in the
`addMustTailToCoroResumes()` function by searching for
`llvm.coro.resume` calls to lower as tail calls if the conditions were
right: the right function arguments, attributes, calling convention
etc., and if a `ret void` was sure to be reached after traversal with
some ad-hoc constant folding following the call.
This was brittle, as the kind of implicit variants required for a tail
call to happen could easily be broken by other passes (e.g. if some
instruction got in between the `resume` and `ret`), see for example
9d1cb18d19862fc0627e4a56e1e491a498e84c71 and
284da049f5feb62b40f5abc41dda7895e3d81d72.
Also the logic seemed backwards: instead of searching for possible tail
call candidates and doing them if the circumstances are right, it seems
better to start with the intention of making the tail calls we need, and
forcing the circumstances to be right.
Now that we have the `llvm.coro.await.suspend.handle` intrinsic (since
f78688134026686288a8d310b493d9327753a022) which corresponds exactly to
symmetric transfer, change the lowering of that to also include the
`resume` part, always lowered as a tail call.
Diffstat (limited to 'llvm/lib/Support/StringExtras.cpp')
0 files changed, 0 insertions, 0 deletions