[PATCH] D153123: Fix diag for read-only target features
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 16 14:49:03 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc8c583071591: Fix diag for read-only target features (authored by yaxunl).
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153123/new/
https://reviews.llvm.org/D153123
Files:
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets.cpp
clang/test/OpenMP/openmp-read-only-feature.c
Index: clang/test/OpenMP/openmp-read-only-feature.c
===================================================================
--- /dev/null
+++ clang/test/OpenMP/openmp-read-only-feature.c
@@ -0,0 +1,16 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+// REQUIRES: clang-target-64-bits
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx1030 \
+// RUN: -fopenmp -nogpulib -fopenmp-is-device -verify %s
+// expected-no-diagnostics
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx1030 \
+// RUN: -fopenmp -nogpulib -target-feature -image-insts \
+// RUN: -fopenmp-is-device -emit-llvm -S -o - %s 2>&1 | FileCheck %s
+// CHECK: warning: feature flag '-image-insts' is ignored since the feature is read only
+
+#pragma omp begin declare variant match(device = {arch(amdgcn)})
+void foo();
+#pragma omp end declare variant
Index: clang/lib/Basic/Targets.cpp
===================================================================
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -42,6 +42,7 @@
#include "Targets/X86.h"
#include "Targets/XCore.h"
#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticFrontend.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/TargetParser/Triple.h"
@@ -816,6 +817,13 @@
// Compute the default target features, we need the target to handle this
// because features may have dependencies on one another.
+ llvm::erase_if(Opts->FeaturesAsWritten, [&](StringRef Name) {
+ if (Target->isReadOnlyFeature(Name.substr(1))) {
+ Diags.Report(diag::warn_fe_backend_readonly_feature_flag) << Name;
+ return true;
+ }
+ return false;
+ });
if (!Target->initFeatureMap(Opts->FeatureMap, Diags, Opts->CPU,
Opts->FeaturesAsWritten))
return nullptr;
Index: clang/lib/Basic/TargetInfo.cpp
===================================================================
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -528,8 +528,6 @@
// Apply the feature via the target.
if (Name[0] != '+' && Name[0] != '-')
Diags.Report(diag::warn_fe_backend_invalid_feature_flag) << Name;
- else if (isReadOnlyFeature(Name.substr(1)))
- Diags.Report(diag::warn_fe_backend_readonly_feature_flag) << Name;
else
setFeatureEnabled(Features, Name.substr(1), Name[0] == '+');
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153123.532299.patch
Type: text/x-patch
Size: 2385 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230616/115071d4/attachment.bin>
More information about the cfe-commits
mailing list