[PATCH v8 02/12] Fix pro_and_epilogue for sibcalls at -O0

Andi Kleen ak@linux.intel.com
Sat Jun 22 18:54:34 GMT 2024


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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/function.cc b/gcc/function.cc
index 4edd4da12474..7c9b181423d4 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,
-- 
2.45.2



More information about the Gcc-patches mailing list