[llvm-branch-commits] [clang] clang: Use proper error for unified shared memory openmp error (PR #212750)
Matt Arsenault via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jul 29 04:54:26 PDT 2026
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/212750
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
>From 8bb083d3e7a63a142d24b2c852515db04410f4b1 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Wed, 29 Jul 2026 13:53:26 +0200
Subject: [PATCH] clang: Use proper error for unified shared memory openmp
error
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
---
clang/include/clang/Basic/DiagnosticCommonKinds.td | 2 ++
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 8 +++-----
clang/test/OpenMP/requires_codegen.cpp | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index f2ed2f4698b8d..201a210dc5f64 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -455,6 +455,8 @@ def warn_omp_gpu_unsupported_clause: Warning<
def warn_omp_gpu_unsupported_modifier_for_clause: Warning<
"modifier '%0' is currently not supported on a GPU for the '%1' clause; modifier ignored">,
InGroup<OpenMPClauses>;
+def err_omp_unified_shared_memory_unsupported : Error<
+ "target architecture '%0' does not support unified addressing">;
// Static Analyzer Core
def err_unknown_analyzer_checker_or_package : Error<
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 40dd45ab26f3a..79b2b275ba100 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -2267,11 +2267,9 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(const OMPRequiresDecl *D) {
!llvm::NVPTX::supportsUnifiedAddressing(llvm::NVPTX::parseArch(CPU))) {
for (const OMPClause *Clause : D->clauselists()) {
if (Clause->getClauseKind() == OMPC_unified_shared_memory) {
- SmallString<256> Buffer;
- llvm::raw_svector_ostream Out(Buffer);
- Out << "Target architecture " << CPU
- << " does not support unified addressing";
- CGM.Error(Clause->getBeginLoc(), Out.str());
+ CGM.getDiags().Report(Clause->getBeginLoc(),
+ diag::err_omp_unified_shared_memory_unsupported)
+ << CPU;
return;
}
}
diff --git a/clang/test/OpenMP/requires_codegen.cpp b/clang/test/OpenMP/requires_codegen.cpp
index 5a641d0be4deb..6fc84abb64004 100644
--- a/clang/test/OpenMP/requires_codegen.cpp
+++ b/clang/test/OpenMP/requires_codegen.cpp
@@ -21,5 +21,5 @@
#endif
#ifdef REGION_DEVICE
-#pragma omp requires unified_shared_memory // expected-error-re {{Target architecture sm_{{20|21|30|32|35|37|50|52|53|60|61|62}} does not support unified addressing}}
+#pragma omp requires unified_shared_memory // expected-error-re {{target architecture 'sm_{{20|21|30|32|35|37|50|52|53|60|61|62}}' does not support unified addressing}}
#endif
More information about the llvm-branch-commits
mailing list