From aca1f9d7cab3dc1a374a7dc0ec6f7a8d02d2869a Mon Sep 17 00:00:00 2001 From: Alex Coplan Date: Thu, 21 Dec 2023 10:52:44 +0000 Subject: aarch64: Prevent moving throwing accesses in ldp/stp pass [PR113093] As the PR shows, there was nothing to prevent the ldp/stp pass from trying to move throwing insns, which lead to an RTL verification failure. This patch fixes that. gcc/ChangeLog: PR target/113093 * config/aarch64/aarch64-ldp-fusion.cc (latest_hazard_before): If the insn is throwing, record the previous insn as a hazard to prevent moving it from the end of the BB. gcc/testsuite/ChangeLog: PR target/113093 * gcc.dg/pr113093.c: New test. --- gcc/config/aarch64/aarch64-ldp-fusion.cc | 7 +++++++ gcc/testsuite/gcc.dg/pr113093.c | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr113093.c (limited to 'gcc') diff --git a/gcc/config/aarch64/aarch64-ldp-fusion.cc b/gcc/config/aarch64/aarch64-ldp-fusion.cc index 0e2c299..59db70e 100644 --- a/gcc/config/aarch64/aarch64-ldp-fusion.cc +++ b/gcc/config/aarch64/aarch64-ldp-fusion.cc @@ -618,6 +618,13 @@ latest_hazard_before (insn_info *insn, rtx *ignore, { insn_info *result = nullptr; + // If the insn can throw then it is at the end of a BB and we can't + // move it, model this by recording a hazard in the previous insn + // which will prevent moving the insn up. + if (cfun->can_throw_non_call_exceptions + && find_reg_note (insn->rtl (), REG_EH_REGION, NULL_RTX)) + return insn->prev_nondebug_insn (); + // Return true if we registered the hazard. auto hazard = [&](insn_info *h) -> bool { diff --git a/gcc/testsuite/gcc.dg/pr113093.c b/gcc/testsuite/gcc.dg/pr113093.c new file mode 100644 index 0000000..af2a334 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr113093.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -fharden-control-flow-redundancy -fnon-call-exceptions" } */ +_Complex long *c; +void init() { *c = 1.0; } -- cgit v1.1