| Issue |
178352
|
| Summary |
Inconsistent and undocumented placement rules for __arm_streaming vs __arm_locally_streaming
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
cielavenir
|
## Summary
Clang enforces inconsistent and undocumented syntax placement rules for the SME streaming attributes `__arm_streaming` and `__arm_locally_streaming`. Although both apply to functions and control SME streaming mode, one is parsed only as a postfix function attribute while the other is parsed only as a declaration specifier. This asymmetry is surprising, not required by ACLE, and causes real-world usability issues.
## Description
When compiling SME-enabled code, Clang accepts the following forms:
```c
__attribute__((target("+sme"))) void ok1(void) __arm_streaming {}
__attribute__((target("+sme"))) __arm_locally_streaming void ok2(void) {}
```
but rejects these otherwise equivalent forms:
```c
__attribute__((target("+sme"))) __arm_streaming void bad1(void) {}
__attribute__((target("+sme"))) void bad2(void) __arm_locally_streaming {}
```
I prepared this minimal reproducer in https://github.com/cielavenir/smetest/tree/d24184a3818bd56e045193458e98df495c6e6112 , whose action https://github.com/cielavenir/smetest/actions/runs/21424244895/job/61689869303 says:
```
test.c:6:33: error: '__arm_streaming' cannot be applied to a declaration
6 | __attribute__((target("+sme"))) __arm_streaming void bad1(void) {}
| ^ ~~~~
test.c:7:49: error: '__arm_locally_streaming' cannot be applied to types
7 | __attribute__((target("+sme"))) void bad2(void) __arm_locally_streaming {}
| ^
2 errors generated.
```
This behavior is highly unintuitive because:
- Both attributes apply to functions
- Both control SME streaming state
- Neither the Arm ACLE nor Clang documentation specifies asymmetric placement rules
- Other function attributes in Clang generally allow consistent prefix/postfix placement via __attribute__
## Expected Behavior
Either:
- Both attributes accept consistent placement (prefix and/or postfix), or
- Clang emits a clear diagnostic documenting the required placement rules
## Actual Behavior
- `__arm_streaming` is accepted only as a postfix function attribute
- `__arm_locally_streaming` is accepted only as a declaration specifier
The difference is undocumented and non-obvious
## Environment
- Clang: Clang/LLVM (Homebrew) 20.1.8 cf https://github.com/actions/runner-images/blob/main/images/macos/macos-26-arm64-Readme.md
- Target: AArch64, SME enabled
- OS: macOS
----
This issue is ChatGPT-assisted https://chatgpt.com/share/6979898d-dedc-8008-89c4-f473c7f00e27 (though his minimal reproducer did not work out-of-box and I needed to fix a bit)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs