[PATCH] D121963: [clang] [OpenMP] Diagnose use of 'target_clones' in OpenMP variant declarations.
Tom Honermann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 17 14:55:04 PDT 2022
tahonermann created this revision.
tahonermann added reviewers: erichkeane, aaron.ballman.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
tahonermann published this revision for review.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.
Previously, OpenMP variant declarations for a function declaration that included
the 'cpu_dispatch', 'cpu_specific', or 'target' attributes was diagnosed, but
one with the 'target_clones' attribute was not. Now fixed.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D121963
Files:
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/declare_variant_messages.c
Index: clang/test/OpenMP/declare_variant_messages.c
===================================================================
--- clang/test/OpenMP/declare_variant_messages.c
+++ clang/test/OpenMP/declare_variant_messages.c
@@ -162,9 +162,8 @@
#pragma omp declare variant(incompat_attr_variant) match(implementation={vendor(llvm)})
__attribute__((target("default"))) void incompat_attr_target_default(void); // expected-error {{'#pragma omp declare variant' is not compatible with any target-specific attributes}}
-// FIXME: No diagnostics are produced for use of the 'target_clones' attribute in an OMP variant declaration.
#pragma omp declare variant(incompat_attr_variant) match(implementation={vendor(llvm)})
-__attribute__((target_clones("sse,default"))) void incompat_attr_target_clones(void);
+__attribute__((target_clones("sse,default"))) void incompat_attr_target_clones(void); // expected-error {{'#pragma omp declare variant' is not compatible with any target-specific attributes}}
void marked(void);
void not_marked(void);
Index: clang/lib/Sema/SemaOpenMP.cpp
===================================================================
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -7032,11 +7032,11 @@
}
auto &&HasMultiVersionAttributes = [](const FunctionDecl *FD) {
- return FD->hasAttrs() &&
- (FD->hasAttr<CPUDispatchAttr>() || FD->hasAttr<CPUSpecificAttr>() ||
- FD->hasAttr<TargetAttr>());
+ // The 'target' attribute needs to be separately checked because it does
+ // not always signify a multiversion function declaration.
+ return FD->isMultiVersion() || FD->hasAttr<TargetAttr>();
};
- // OpenMP is not compatible with CPU-specific attributes.
+ // OpenMP is not compatible with multiversion function attributes.
if (HasMultiVersionAttributes(FD)) {
Diag(FD->getLocation(), diag::err_omp_declare_variant_incompat_attributes)
<< SR;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121963.416328.patch
Type: text/x-patch
Size: 1939 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220317/4958dca6/attachment.bin>
More information about the cfe-commits
mailing list