https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113805

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <rsand...@gcc.gnu.org>:

https://gcc.gnu.org/g:98702303e2b0e540b25c94805ca015688f78250e

commit r14-9080-g98702303e2b0e540b25c94805ca015688f78250e
Author: Richard Sandiford <richard.sandif...@arm.com>
Date:   Tue Feb 20 11:29:06 2024 +0000

    aarch64: Fix streaming-compatible code with -mtrack-speculation [PR113805]

    This patch makes -mtrack-speculation work on streaming-compatible
    functions.  There were two related issues.  The first is that the
    streaming-compatible code was using TB(N)Z unconditionally, whereas
    those instructions are not allowed with speculation tracking.
    That part can be fixed in a similar way to the recent eh_return
    fix (PR112987).

    The second issue was that the speculation-tracking pass runs
    before some of the conditional branches are inserted.  It isn't
    safe to insert the branches any earlier, so the patch instead adds
    a second speculation-tracking pass that runs afterwards.  The new
    pass is only used for streaming-compatible functions.

    The testcase is adapted from call_sm_switch_1.c.

    gcc/
            PR target/113805
            * config/aarch64/aarch64-passes.def (pass_late_track_speculation):
            New pass.
            * config/aarch64/aarch64-protos.h
(make_pass_late_track_speculation):
            Declare.
            * config/aarch64/aarch64.md (is_call): New attribute.
            (*and<mode>3nr_compare0): Rename to...
            (@aarch64_and<mode>3nr_compare0): ...this.
            * config/aarch64/aarch64-sme.md (aarch64_get_sme_state)
            (aarch64_tpidr2_save, aarch64_tpidr2_restore): Add is_call
attributes.
            * config/aarch64/aarch64-speculation.cc: Update file comment to
            describe the new late pass.
            (aarch64_do_track_speculation): Handle is_call insns like other
calls.
            (pass_track_speculation): Add an is_late member variable.
            (pass_track_speculation::gate): Run the late pass for streaming-
            compatible functions and the early pass for other functions.
            (make_pass_track_speculation): Update accordingly.
            (make_pass_late_track_speculation): New function.
            * config/aarch64/aarch64.cc (aarch64_gen_test_and_branch): New
            function.
            (aarch64_guard_switch_pstate_sm): Use it.

    gcc/testsuite/
            PR target/113805
            * gcc.target/aarch64/sme/call_sm_switch_11.c: New test.

Reply via email to