https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108876
Bug ID: 108876 Summary: return address clobbered in sibcalls resulting in gfortran tests failing on xtensa Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: jcmvbkbc at gcc dot gnu.org Target Milestone: --- A number of gfortran tests built with -O3 fail with segfault on call0 xtensa config. E.g. gfortran.dg/allocate_with_source_5.f90 It fails because of the following sibcall code in the __selectors_MOD_selector_init: .L445: l32i a0, sp, 300 l32i a2, sp, 192 l32i a4, sp, 204 l32i a12, sp, 296 l32i a13, sp, 292 l32i a14, sp, 288 l32i a15, sp, 284 movi a0, 0x130 add.n sp, sp, a0 jx a4 RTL generated for this fragment initially looks like this: (note 3983 3749 3975 121 NOTE_INSN_EPILOGUE_BEG) (insn 3975 3983 3976 121 (set (reg:SI 0 a0) (mem/c:SI (plus:SI (reg/f:SI 1 sp) (const_int 300 [0x12c])) [31 S4 A32])) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 -1 (nil)) (insn 3976 3975 3977 121 (set (reg:SI 12 a12) (mem/c:SI (plus:SI (reg/f:SI 1 sp) (const_int 296 [0x128])) [31 S4 A32])) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 -1 (nil)) (insn 3977 3976 3978 121 (set (reg:SI 13 a13) (mem/c:SI (plus:SI (reg/f:SI 1 sp) (const_int 292 [0x124])) [31 S4 A32])) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 -1 (nil)) (insn 3978 3977 3979 121 (set (reg:SI 14 a14) (mem/c:SI (plus:SI (reg/f:SI 1 sp) (const_int 288 [0x120])) [31 S4 A32])) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 -1 (nil)) (insn 3979 3978 3980 121 (set (reg:SI 15 a15) (mem/c:SI (plus:SI (reg/f:SI 1 sp) (const_int 284 [0x11c])) [31 S4 A32])) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 -1 (nil)) (insn 3980 3979 3981 121 (use (reg:SI 0 a0)) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 -1 (nil)) (insn 3981 3980 3982 121 (set (reg:SI 9 a9) (const_int 304 [0x130])) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 -1 (nil)) (insn 3982 3981 760 121 (set (reg/f:SI 1 sp) (plus:SI (reg/f:SI 1 sp) (reg:SI 9 a9))) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 -1 (nil)) (call_insn/j 760 3982 761 121 (call (mem:SI (reg:SI 6 a6) [0 __builtin_free S4 A32]) (const_int 0 [0])) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 discrim 1 106 {sibcall_internal} (expr_list:REG_CALL_DECL (symbol_ref:SI ("free") [flags 0x41] <function_decl 0x7f98b2fa3000 __builtin_free>) (expr_list:REG_EH_REGION (const_int 0 [0]) (nil))) (expr_list:SI (use (reg:SI 2 a2)) (nil))) but then in the rnreg pass it is changed to the following: (note 3983 3749 3975 121 NOTE_INSN_EPILOGUE_BEG) (insn 3975 3983 3976 121 (set (reg:SI 0 a0) (mem/c:SI (plus:SI (reg/f:SI 1 sp) (const_int 300 [0x12c])) [31 S4 A32])) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 53 {movsi_internal} (nil)) (insn 3976 3975 3977 121 (set (reg:SI 12 a12) (mem/c:SI (plus:SI (reg/f:SI 1 sp) (const_int 296 [0x128])) [31 S4 A32])) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 53 {movsi_internal} (nil)) (insn 3977 3976 3978 121 (set (reg:SI 13 a13) (mem/c:SI (plus:SI (reg/f:SI 1 sp) (const_int 292 [0x124])) [31 S4 A32])) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 53 {movsi_internal} (nil)) (insn 3978 3977 3979 121 (set (reg:SI 14 a14) (mem/c:SI (plus:SI (reg/f:SI 1 sp) (const_int 288 [0x120])) [31 S4 A32])) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 53 {movsi_internal} (nil)) (insn 3979 3978 3980 121 (set (reg:SI 15 a15) (mem/c:SI (plus:SI (reg/f:SI 1 sp) (const_int 284 [0x11c])) [31 S4 A32])) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 53 {movsi_internal} (nil)) (insn 3980 3979 3981 121 (use (reg:SI 0 a0)) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 -1 (expr_list:REG_DEAD (reg:SI 0 a0) (nil))) (insn 3981 3980 3982 121 (set (reg:SI 0 a0) (const_int 304 [0x130])) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 53 {movsi_internal} (nil)) (insn 3982 3981 760 121 (set (reg/f:SI 1 sp) (plus:SI (reg/f:SI 1 sp) (reg:SI 0 a0))) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 1 {addsi3} (expr_list:REG_DEAD (reg:SI 9 a9) (nil))) (call_insn/j 760 3982 761 121 (call (mem:SI (reg:SI 4 a4) [0 __builtin_free S4 A32]) (const_int 0 [0])) "gcc/testsuite/gfortran.dg/allocate_with_source_5.f90":35:30 discrim 1 106 {sibcall_internal} (expr_list:REG_DEAD (reg:SI 6 a6) (expr_list:REG_DEAD (reg:SI 2 a2) (expr_list:REG_CALL_DECL (symbol_ref:SI ("free") [flags 0x41] <function_decl 0x7f98b2fa3000 __builtin_free>) (expr_list:REG_EH_REGION (const_int 0 [0]) (nil))))) (expr_list:SI (use (reg:SI 2 a2)) (nil)))