Recent commit introduced a conditional branch in eh_return epilogues that is not compatible with speculation tracking:
commit 426fddcbdad6746fe70e031f707fb07f55dfb405 Author: Szabolcs Nagy <szabolcs.n...@arm.com> CommitDate: 2023-11-27 15:52:48 +0000 aarch64: Use br instead of ret for eh_return gcc/ChangeLog: PR target/112987 * config/aarch64/aarch64.cc (aarch64_expand_epilogue): Use explicit compare and separate jump with speculation tracking. --- gcc/config/aarch64/aarch64.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index e6bd3fd0bb4..e6de62dc02a 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -9879,7 +9879,17 @@ aarch64_expand_epilogue (rtx_call_insn *sibcall) is just as correct as retaining the CFA from the body of the function. Therefore, do nothing special. */ rtx label = gen_label_rtx (); - rtx x = gen_rtx_EQ (VOIDmode, EH_RETURN_TAKEN_RTX, const0_rtx); + rtx x; + if (aarch64_track_speculation) + { + /* Emit an explicit compare, so cc can be tracked. */ + rtx cc_reg = aarch64_gen_compare_reg (EQ, + EH_RETURN_TAKEN_RTX, + const0_rtx); + x = gen_rtx_EQ (GET_MODE (cc_reg), cc_reg, const0_rtx); + } + else + x = gen_rtx_EQ (VOIDmode, EH_RETURN_TAKEN_RTX, const0_rtx); x = gen_rtx_IF_THEN_ELSE (VOIDmode, x, gen_rtx_LABEL_REF (Pmode, label), pc_rtx); rtx jump = emit_jump_insn (gen_rtx_SET (pc_rtx, x)); -- 2.25.1