the people require __attribute__((__musttail__)) in gcc. we require it
Conversation
Notices
-
Embed this notice
Andy Wingo (wingo@mastodon.social)'s status on Thursday, 15-Jun-2023 06:27:35 JST Andy Wingo - clacke likes this.
-
Embed this notice
Laurence Tratt (ltratt@mastodon.social)'s status on Thursday, 15-Jun-2023 06:27:39 JST Laurence Tratt @stephenrkell @cfbolz @wingo Many years ago I wrote a blog post on the downsides of tail calls on debugging https://tratt.net/laurie/blog/2004/tail_call_optimization.html only to discover later that at least one paper (Smith and Ungar, cited at the end in an update) had also alluded to the problem. I've sometimes wondered: how soon after tail calls were introduced did the debugging downsides become known?
clacke likes this. -
Embed this notice
Stephen Kell (stephenrkell@recurse.social)'s status on Thursday, 15-Jun-2023 06:27:44 JST Stephen Kell @cfbolz @wingo Tangential, but one of the tricky things I sometimes think about is how to reconcile tail-call optimisation with debuggability. Do you have a take?
E.g. with tail recursion, even supposing you can reconstruct the stack depth and locals from ambient other state, it's not expressible within DWARF to 'synthesise n frames, computed like so'... and it'd probably be a misfeature even if it were. What should happen?
Sibling tail-call opt is even trickier... I often tell it to -f off.
-
Embed this notice
CF Bolz-Tereick (cfbolz@mastodon.social)'s status on Thursday, 15-Jun-2023 06:27:47 JST CF Bolz-Tereick @wingo oh yes, that would be excellent
-
Embed this notice
Andy Wingo (wingo@mastodon.social)'s status on Thursday, 15-Jun-2023 06:27:49 JST Andy Wingo @ltratt @stephenrkell @cfbolz i think in this concrete case there is no issue because it's something the programmer intends, rather than an unexpected optimization. would be weird to see a stack frame when you explicitly asked not to have one :)
clacke likes this. -
Embed this notice
Andy Wingo (wingo@mastodon.social)'s status on Thursday, 15-Jun-2023 06:27:51 JST Andy Wingo @ltratt @stephenrkell @cfbolz ok gotta be pedantic here, what is being opted into is proper tail calls, not tail call *optimization*; clang::musttail means tail calls even when -O0
clacke likes this. -
Embed this notice
Laurence Tratt (ltratt@mastodon.social)'s status on Thursday, 15-Jun-2023 06:27:52 JST Laurence Tratt @wingo @stephenrkell @cfbolz I agree -- when one opts in to TCO, one implicitly accepts the lack of stack traces.
-
Embed this notice
Stephen Kell (stephenrkell@recurse.social)'s status on Thursday, 15-Jun-2023 06:27:54 JST Stephen Kell @wingo @ltratt @cfbolz Time for my pedantry... let's not mix 'stack traces' (a debugging feature) with 'stack frame' (a memory allocation). Stack traces already include 'frames' that do not correspond to any physical frame, thanks to inlining
(That is another example of something that can be done at -O0, via always_inline, and straddles 'correctness' vs 'optimisation'. For TC[O] it depends whether you classify asymptotic space usage as functional or extrafunctional... the use case matters.)
clacke likes this. -
Embed this notice
clacke (clacke@libranet.de)'s status on Thursday, 15-Jun-2023 06:27:54 JST clacke @jamesh @wingo Being a normal person is overrated. -
Embed this notice
James Henstridge (jamesh@aus.social)'s status on Thursday, 15-Jun-2023 06:28:00 JST James Henstridge @wingo Or you could just learn to use while loops like a normal person 😃