[llvm] [AArch64][SME] Save VG for unwind info when changing streaming-mode (PR #83301)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 15 08:13:15 PDT 2024


sdesmalen-arm wrote:

> The problem case is "non-streaming SVE-enabled caller -> locally-streaming SVE-disabled callee". The caller doesn't set VG because it doesn't know anything about streaming. The callee can't set VG because it can't read the non-streaming vector length. The only way I can think of to make it work, given the specified structure of the unwind data, is a runtime check for whether SVE is available. But the ABI doesn't provide any way to check that at the moment.

If I understand you correctly, you're concerned about the following case:
```
__attribute__((target("+sme,+nosve")))
void c() __arm_streaming {
  ...
}

__attribute__((target("+sme,+nosve"))
void b() { c(); }

__attribute__((target("+sve")))
void a() { b(); }
```

where in `b()` it's not possible to read and save VG (since the function is compiled with +nosve and the function is not in streaming mode), so when unwinding from `c->b->a` there is no information to tell the unwinder/debugger what the value of VG is inside `a()`.

I think the critical point here is that having SME without also having SVE available in non-streaming mode is an atypical use-case for which the ABI was never really intended. SME is an Armv9-A feature which generally expects SVE to be available (in non-streaming mode), similar to how Armv8-A generally expects AdvSIMD to be available (see note in section A1.5 of the Arm Reference Manual). In LLVM we have tried to keep the two features conceptually separate so not to tie ourselves in in case this requirement ever needs to be relaxed.

If this is a use-case that ever needs supporting in the ABI, I guess this could be done by adding an extra ABI routine that safely provides the current value of VG iff SVE is available at runtime.

https://github.com/llvm/llvm-project/pull/83301


More information about the llvm-commits mailing list