On Sun, Jun 2, 2024, 10:24 AM Andi Kleen <a...@linux.intel.com> wrote:
> Some of the cfg fixups in pro_and_epilogue for sibcalls were dependent on > "optimize". > Make them check cfun->tail_call_marked instead to handle the -O0 musttail > case. This fixes the musttail test cases on arm targets. > > PR115255 > > gcc/ChangeLog: > > * function.cc (thread_prologue_and_epilogue_insns): Check > cfun->tail_call_marked for sibcalls too. > (rest_of_handle_thread_prologue_and_epilogue): Dito. > --- > gcc/function.cc | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/gcc/function.cc b/gcc/function.cc > index 4edd4da12474..f949c38b916c 100644 > --- a/gcc/function.cc > +++ b/gcc/function.cc > @@ -6261,6 +6261,7 @@ thread_prologue_and_epilogue_insns (void) > /* Threading the prologue and epilogue changes the artificial refs in > the > entry and exit blocks, and may invalidate DF info for tail calls. */ > if (optimize > + || cfun->tail_call_marked > || flag_optimize_sibling_calls > || flag_ipa_icf_functions > || in_lto_p) > @@ -6557,7 +6558,7 @@ rest_of_handle_thread_prologue_and_epilogue > (function *fun) > { > /* prepare_shrink_wrap is sensitive to the block structure of the > control > flow graph, so clean it up first. */ > - if (optimize) > + if (cfun->tail_call_marked || optimize) > cleanup_cfg (0); > > /* On some machines, the prologue and epilogue code, or parts thereof, > @@ -6579,7 +6580,7 @@ rest_of_handle_thread_prologue_and_epilogue > (function *fun) > > /* Shrink-wrapping can result in unreachable edges in the epilogue, > see PR57320. */ > - cleanup_cfg (optimize ? CLEANUP_EXPENSIVE : 0); > + cleanup_cfg ((cfun->tail_call_marked || optimize) ? CLEANUP_EXPENSIVE : > 0); > I think this makes -g -O0 with musttail useless. Make sure if you have a musttail function call in the ir that it does not change the cfg for -O0 case which adds extra jumps specifically for debugging. Thanks, Andrew > /* The stack usage info is finalized during prologue expansion. */ > if (flag_stack_usage_info || flag_callgraph_info) > -- > 2.44.0 > >