Hi Suwa-san, On Mon, Jun 13, 2022 at 8:54 PM Takayuki 'January June' Suwa <jjsuwa_sys3...@yahoo.co.jp> wrote: > > This patch introduces support for sibling call optimization, when call0 > ABI is in effect. > > gcc/ChangeLog: > > * config/xtensa/xtensa-protos.h (xtensa_prepare_expand_call, > xtensa_emit_sibcall): New prototypes. > (xtensa_expand_epilogue): Add new argument that specifies whether > or not sibling call. > * config/xtensa/xtensa.cc (TARGET_FUNCTION_OK_FOR_SIBCALL): > New macro definition. > (xtensa_prepare_expand_call): New function in order to share > the common code. > (xtensa_emit_sibcall, xtensa_function_ok_for_sibcall): > New functions. > (xtensa_expand_epilogue): Add new argument sibcall_p and use it > for sibling call handling. > * config/xtensa/xtensa.md (call, call_value): > Use xtensa_prepare_expand_call. > (call_internal, call_value_internal): > Add the condition in order to be disabled if sibling call. > (sibcall, sibcall_value, sibcall_epilogue): New expansions. > (sibcall_internal, sibcall_value_internal): New insn patterns. > > gcc/testsuite/ChangeLog: > > * gcc.target/xtensa/sibcalls.c: New. > --- > gcc/config/xtensa/xtensa-protos.h | 4 +- > gcc/config/xtensa/xtensa.cc | 63 ++++++++++++++++++-- > gcc/config/xtensa/xtensa.md | 68 +++++++++++++++++----- > gcc/testsuite/gcc.target/xtensa/sibcalls.c | 15 +++++ > 4 files changed, 130 insertions(+), 20 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/xtensa/sibcalls.c
This change results in a bunch of new regression test failures: FAIL: gcc.c-torture/execute/builtins/fprintf.c execution, -O2 FAIL: gcc.c-torture/execute/builtins/fprintf.c execution, -O3 -g FAIL: gcc.c-torture/execute/builtins/fprintf.c execution, -Os FAIL: gcc.c-torture/execute/builtins/fprintf.c execution, -O2 -flto -fno-use-linker-plugin -flto-partition=none FAIL: gcc.c-torture/execute/builtins/memset.c execution, -O2 FAIL: gcc.c-torture/execute/builtins/memset.c execution, -O3 -g FAIL: gcc.c-torture/execute/builtins/memset.c execution, -Os FAIL: gcc.c-torture/execute/builtins/memset.c execution, -O2 -flto -fno-use-linker-plugin -flto-partition=none FAIL: gcc.c-torture/execute/builtins/printf.c execution, -O2 FAIL: gcc.c-torture/execute/builtins/printf.c execution, -O3 -g FAIL: gcc.c-torture/execute/builtins/printf.c execution, -Os FAIL: gcc.c-torture/execute/builtins/printf.c execution, -O2 -flto -fno-use-linker-plugin -flto-partition=none FAIL: gcc.c-torture/execute/builtins/strcpy-2.c execution, -O2 FAIL: gcc.c-torture/execute/builtins/strcpy-2.c execution, -O2 -flto -fno-use-linker-plugin -flto-partition=none FAIL: gcc.c-torture/execute/builtins/strcpy-2.c execution, -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects FAIL: gcc.c-torture/execute/20000121-1.c -O2 execution test FAIL: gcc.c-torture/execute/20000121-1.c -O3 -g execution test FAIL: gcc.c-torture/execute/20000121-1.c -Os execution test FAIL: gcc.c-torture/execute/20000121-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/921208-2.c -O2 execution test FAIL: gcc.c-torture/execute/921208-2.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gcc.c-torture/execute/921208-2.c -O3 -g execution test FAIL: gcc.c-torture/execute/921208-2.c -Os execution test FAIL: gcc.c-torture/execute/921208-2.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/pr33992.c -O2 execution test FAIL: gcc.c-torture/execute/pr33992.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gcc.c-torture/execute/pr33992.c -O3 -g execution test FAIL: gcc.c-torture/execute/pr33992.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/pr49161.c -O2 execution test FAIL: gcc.c-torture/execute/pr49161.c -O3 -g execution test FAIL: gcc.c-torture/execute/pr49161.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/pr88714.c -O2 execution test FAIL: gcc.c-torture/execute/pr88714.c -O3 -g execution test FAIL: gcc.c-torture/execute/pr88714.c -Os execution test FAIL: gcc.c-torture/execute/pr88714.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/pr88714.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.c-torture/execute/pr88739.c -O2 execution test FAIL: gcc.c-torture/execute/pr88739.c -O3 -g execution test FAIL: gcc.c-torture/execute/pr88739.c -Os execution test FAIL: gcc.c-torture/execute/pr88739.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/pr90949.c -O2 execution test FAIL: gcc.c-torture/execute/pr90949.c -O3 -g execution test FAIL: gcc.c-torture/execute/pr90949.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/pr90949.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.c-torture/execute/printf-2.c -O2 execution test FAIL: gcc.c-torture/execute/printf-2.c -O3 -g execution test FAIL: gcc.c-torture/execute/printf-2.c -Os execution test FAIL: gcc.c-torture/execute/printf-2.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/printf-2.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.dg/packed-array.c execution test FAIL: gcc.dg/pr20115.c execution test FAIL: gcc.dg/pr44404.c execution test FAIL: gcc.dg/pr81292-2.c execution test FAIL: gcc.dg/strlenopt-31.c execution test FAIL: gcc.dg/strlenopt-81.c execution test FAIL: gcc.dg/torture/builtin-complex-1.c -O2 execution test FAIL: gcc.dg/torture/builtin-complex-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gcc.dg/torture/builtin-complex-1.c -O3 -g execution test FAIL: gcc.dg/torture/builtin-complex-1.c -Os execution test FAIL: gcc.dg/torture/builtin-complex-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.dg/torture/pr56661.c -Os execution test FAIL: gcc.dg/torture/pr65077.c -O2 execution test FAIL: gcc.dg/torture/pr65077.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gcc.dg/torture/pr65077.c -O3 -g execution test FAIL: gcc.dg/torture/pr65077.c -Os execution test FAIL: gcc.dg/torture/pr65077.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.dg/torture/pr67916.c -O2 execution test FAIL: gcc.dg/torture/pr67916.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gcc.dg/torture/pr67916.c -O3 -g execution test FAIL: gcc.dg/torture/pr67916.c -Os execution test FAIL: gcc.dg/torture/pr67916.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.dg/tree-ssa/cswtch-3.c execution test FAIL: gcc.dg/tree-ssa/predcom-dse-5.c execution test FAIL: gcc.dg/tree-ssa/predcom-dse-6.c execution test FAIL: gcc.dg/tree-ssa/predcom-dse-7.c execution test The code generated for e.g. gcc.c-torture/execute/921208-2.c looks like this: .file "921208-2.c" .text .literal_position .align 4 .global g .type g, @function g: ret.n .size g, .-g .literal_position .literal .LC1, g@PLT .literal .LC3, 1072693248 .literal .LC4, 1073741824 .align 4 .global f .type f, @function f: addi sp, sp, -16 s32i.n a13, sp, 4 l32r a13, .LC3 s32i.n a12, sp, 8 s32i.n a14, sp, 0 movi.n a12, 0 l32r a14, .LC1 s32i.n a0, sp, 12 mov.n a3, a13 mov.n a4, a12 mov.n a5, a13 mov.n a2, a12 callx0 a14 l32i.n a0, sp, 12 l32i.n a14, sp, 0 mov.n a4, a12 mov.n a5, a13 l32i.n a12, sp, 8 l32i.n a13, sp, 4 l32r a3, .LC4 movi.n a2, 0 addi sp, sp, 16 jx a14 .size f, .-f .section .text.startup,"ax",@progbits .literal_position .literal .LC5, f@PLT .literal .LC6, exit@PLT .align 4 .global main .type main, @function main: addi sp, sp, -16 l32r a2, .LC5 s32i.n a0, sp, 12 callx0 a2 l32r a3, .LC6 movi.n a2, 0 callx0 a3 .size main, .-main .ident "GCC: (GNU) 13.0.0 20220614 (experimental)" -- Thanks. -- Max