[PATCH] D106550: [PowerPC] Allow MMA builtins to accept restrict qualified pointers
Ahsan Saghir via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 5 07:50:21 PDT 2021
saghir updated this revision to Diff 364467.
saghir added a comment.
Addressed review comments. Added another test case.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106550/new/
https://reviews.llvm.org/D106550
Files:
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/ppc-pair-mma-types.c
Index: clang/test/Sema/ppc-pair-mma-types.c
===================================================================
--- clang/test/Sema/ppc-pair-mma-types.c
+++ clang/test/Sema/ppc-pair-mma-types.c
@@ -333,3 +333,13 @@
__vector_pair vp = __builtin_vsx_lxvp(ll, v); // expected-error {{passing '__vector int' (vector of 4 'int' values) to parameter of incompatible type 'const __vector_pair *'}}
__builtin_vsx_stxvp(vp, ll, s); // expected-error {{passing 'unsigned short' to parameter of incompatible type 'const __vector_pair *'}}
}
+
+void testRestrictQualifiedPointer1(int *__restrict acc) {
+ vector float arr[4];
+ __builtin_mma_disassemble_acc((void*)arr, acc); // expected-error {{passing 'int *restrict' to parameter of incompatible type '__vector_quad *'}}
+}
+
+void testRestrictQualifiedPointer2(__vector_quad *__restrict acc) {
+ vector float arr[4];
+ __builtin_mma_disassemble_acc((void*)arr, acc);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -7324,9 +7324,22 @@
Expr *Arg = TheCall->getArg(ArgNum);
QualType ArgType = Arg->getType();
- if ((ExpectedType->isVoidPointerType() && !ArgType->isPointerType()) ||
- (!ExpectedType->isVoidPointerType() &&
- ArgType.getCanonicalType() != ExpectedType))
+ // Checks if the argument type is valid. Returns true if it is valid
+ // and false if it is not valid.
+ auto IsValidType = [ArgType, ExpectedType]() {
+ if (ExpectedType->isVoidPointerType() && !ArgType->isPointerType())
+ return false;
+ if (!ExpectedType->isVoidPointerType()) {
+ if (ArgType.isRestrictQualified() &&
+ ArgType.getCanonicalType().getUnqualifiedType() == ExpectedType)
+ return true;
+ if (ArgType.getCanonicalType() != ExpectedType)
+ return false;
+ }
+ return true;
+ };
+
+ if (!IsValidType())
return Diag(Arg->getBeginLoc(), diag::err_typecheck_convert_incompatible)
<< ArgType << ExpectedType << 1 << 0 << 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106550.364467.patch
Type: text/x-patch
Size: 2150 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210805/3d06b387/attachment.bin>
More information about the cfe-commits
mailing list