[PATCH] D150867: [AArch64][FMV] Prevent target attribute using for multiversioning.
Pavel Iliin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 18 06:04:04 PDT 2023
ilinpv created this revision.
ilinpv added a reviewer: danielkiss.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
ilinpv requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
On AArch64 for function multiversioning target_version/target_clones attributes should be used. The patch fixes the defect allowing target attribute to cause multiversioning.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D150867
Files:
clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/attr-target-version.c
Index: clang/test/Sema/attr-target-version.c
===================================================================
--- clang/test/Sema/attr-target-version.c
+++ clang/test/Sema/attr-target-version.c
@@ -15,15 +15,22 @@
//expected-note at +1 {{previous definition is here}}
int __attribute__((target_version("default"))) foo(void) { return 2; }
-//expected-note at +1 {{previous declaration is here}}
+//expected-note at +1 {{previous definition is here}}
int __attribute__((target_version("sha3 + pmull "))) foo(void) { return 1; }
+//expected-note at -1 {{previous definition is here}}
-//expected-error at +1 {{multiversioning attributes cannot be combined}}
+//expected-error at +1 {{redefinition of 'foo'}}
int __attribute__((target("dotprod"))) foo(void) { return -1; }
+//expected-warning at -1 {{attribute declaration must precede definition}}
//expected-error at +1 {{redefinition of 'foo'}}
int foo(void) { return 2; }
+//expected-note at +1 {{previous definition is here}}
+__attribute__ ((target("bf16,sve,sve2,dotprod"))) int func(void) { return 1; }
+//expected-error at +1 {{redefinition of 'func'}}
+__attribute__ ((target("default"))) int func(void) { return 0; }
+
//expected-note at +1 {{previous declaration is here}}
void __attribute__((target_version("bti+flagm2"))) one(void) {}
//expected-error at +1 {{multiversioned function redeclarations require identical target attributes}}
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11540,6 +11540,10 @@
return false;
}
+ // Target attribute on AArch64 is not used for multiversioning
+ if (NewTA && S.getASTContext().getTargetInfo().getTriple().isAArch64())
+ return false;
+
if (!OldDecl || !OldDecl->getAsFunction() ||
OldDecl->getDeclContext()->getRedeclContext() !=
NewFD->getDeclContext()->getRedeclContext()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150867.523353.patch
Type: text/x-patch
Size: 1924 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230518/d01d7a0e/attachment.bin>
More information about the cfe-commits
mailing list