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

            Bug ID: 128573
           Summary: AArch64 SME: ICE in aarch64_old_svcr_mem for
                    __builtin_longjmp in an __arm_streaming_compatible
                    function
           Product: gcc
           Version: 16.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 220245569 at seu dot edu.cn
                CC: 220255623 at seu dot edu.cn, jianhao.xu at seu dot edu.cn
  Target Milestone: ---
            Target: aarch64-*-linux-gnu

Summary
-------
GCC 16.2.0 targeting aarch64-linux-gnu crashes in the smstarts RTL pass when
compiling __builtin_longjmp in an __arm_streaming_compatible function with SME
and -mtrack-speculation.

Reproducer
----------
$ cat trigger.c
void *buf[5];

void nlg_streaming(void) __arm_streaming {
    __builtin_longjmp(buf, 1);
}

void nlg_compat(void) __arm_streaming_compatible {
    __builtin_longjmp(buf, 1);
}

Compile flag:
$ aarch64-linux-gnu-gcc -O2 -march=armv9-a+sme -mtrack-speculation -S trigger.c
-o trigger.s

Observed diagnostic (input was supplied on stdin with -x c -):
during RTL pass: smstarts
<stdin>: In function 'nlg_compat':
<stdin>:9:1: internal compiler error: in aarch64_old_svcr_mem, at
config/aarch64/aarch64.cc:10437
0x291acbf internal_error(char const*, ...)
    /build/gcc//src/gcc/diagnostic-global-context.cc:787
0x291f35b fancy_abort(char const*, int, char const*)
    /build/gcc//src/gcc/diagnostics/context.cc:1813
0x27a5c08 aarch64_old_svcr_mem()
    /build/gcc//src/gcc/config/aarch64/aarch64.cc:10436
0x27d7aeb aarch64_read_old_svcr(unsigned int)
    /build/gcc//src/gcc/config/aarch64/aarch64.cc:10454
0x27d7aeb aarch64_guard_switch_pstate_sm(unsigned int, unsigned long)
    /build/gcc//src/gcc/config/aarch64/aarch64.cc:10466
0x27d7aeb aarch64_switch_pstate_sm_for_jump(rtx_insn*)
    /build/gcc//src/gcc/config/aarch64/aarch64.cc:32636
0x27d7aeb (anonymous namespace)::pass_switch_pstate_sm::execute(function*)
    /build/gcc//src/gcc/config/aarch64/aarch64.cc:32760

Expected behavior
-----------------
Compile the function without an internal compiler error. This is a compile-only
reproducer; buf represents the storage populated by a corresponding
__builtin_setjmp in a caller.

Possible cause / Suggested Fix
-----------------------------
The non-local-jump path in aarch64_switch_pstate_sm_for_jump requests the saved
SVCR through aarch64_old_svcr_mem, whose assertion requires
cfun->machine->old_svcr_stack_slot to exist. The slot is absent in this case.

Please review how the saved SVCR slot is allocated for streaming-compatible
functions with non-local exits. This report is limited to the reproducible ICE.

Reply via email to