rsandifo-arm added a comment.

Thanks for dropping the attribute requirements down to TargetAArch64.  But the 
offsetting requirement was that something somewhere (CodeGen?) must raise an 
error if code requires SME and SME isn't present.  I think that means:

1. SME is not enabled for an `__arm_streaming` or `__arm_locally_streaming` 
function definition.
2. SME is not enabled for a call to an `__arm_streaming` function.
3. SME is not enabled for an `__arm_shared_za` or `__arm_new_za` function 
definition.

(Calls to `__arm_shared_za` functions don't need to be listed explicitly, since 
only `__arm_shared_za` and `__arm_new_za` functions can make such calls.)

In all cases, the check would apply after `__attribute__((target_version))` is 
taken into account.

Perhaps that's a separate patch though.



================
Comment at: clang/include/clang/Basic/AttrDocs.td:6645
+responsibility to do this.  Clang will ensure that the generated code in
+streaming-compatible functions is valid in either mode (PSTATE.SM=0 or
+PSTATE.SM=1). For example, if an ``__arm_streaming_compatible`` function calls 
a
----------------



================
Comment at: clang/test/Sema/aarch64-sme-func-attrs.c:186
+struct S2_2 : public S {
+// expected-cpp-error@+2 {{virtual function 'shared_za_memberfn' has different 
attributes ('void () __arm_shared_za __arm_preserves_za') than the function it 
overrides (which has 'void () __arm_shared_za')}}
+// expected-cpp-note@-11 {{overridden virtual function is here}}
----------------
Thanks, this is indeed the case I was suggesting to test.  But my point was 
that it shouldn't be an error.  It's OK for an override to be 
`__arm_preserves_za` even if the function it overrides isn't.  Something that 
calls `shared_za_member` directly from an `S2_2` object can take advantage of 
the extra guarantee.

It's the other way that's wrong.  If a virtual function is `__arm_preserves_za` 
then any override must be too.

The principle is similar to covariant return types. E.g.:
```
struct S1 { virtual S1 *f(); };
struct S2 : S1 { S2 *f() override; }; // OK
struct S3 : S2 { S2 *f() override; }; // OK
struct S4 : S3 { S1 *f() override; }; // Error
```
An `__arm_preserves_za` function acts like functions that return `S2 *` in this 
example, and a non-`__arm_preserves_za` function acts like functions that 
return `S1 *`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127762/new/

https://reviews.llvm.org/D127762

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to