[llvm-branch-commits] [clang] clang: Use proper error for unified shared memory openmp error (PR #212750)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jul 29 04:55:30 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-codegen
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
Co-authored-by: Claude (Claude-Opus-4.8) <noreply@<!-- -->anthropic.com>
---
Full diff: https://github.com/llvm/llvm-project/pull/212750.diff
3 Files Affected:
- (modified) clang/include/clang/Basic/DiagnosticCommonKinds.td (+2)
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+3-5)
- (modified) clang/test/OpenMP/requires_codegen.cpp (+1-1)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/212750
More information about the llvm-branch-commits
mailing list