aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorMichael Halkenhaeuser <MichaelGerald.Halkenhauser@amd.com>2023-03-22 10:45:08 +0100
committerMichael Halkenhaeuser <MichaelGerald.Halkenhauser@amd.com>2023-03-29 11:31:17 +0200
commit55916de2d37742fe334c0726ccf9e584bdaed09f (patch)
treeb6626e4aaca6e4ecdaaeeecef8a45f6c7381c5b1 /clang/lib/Sema/SemaOpenMP.cpp
parentf4b2360cecd4c92e85bccb1443f2ef425fc6a77b (diff)
downloadllvm-55916de2d37742fe334c0726ccf9e584bdaed09f.zip
llvm-55916de2d37742fe334c0726ccf9e584bdaed09f.tar.gz
llvm-55916de2d37742fe334c0726ccf9e584bdaed09f.tar.bz2
[clang][HIP][OpenMP] Add warning if mixed HIP / OpenMP offloading
Adds a warning, issued by the clang semantic analysis, if HIP and OpenMP target offloading is requested concurrently. That is, if HIP language mode is active but OpenMP target directives are encountered. Previously, a user might not have been aware that target directives are ignored in such a case. Generation of this warning is (lit-)tested via "make check-clang-semaopenmp". The warning can be ignored via "-Wno-hip-omp-target-directives". Differential Revision: https://reviews.llvm.org/D145591
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 1cd263b..08ca536 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -6122,6 +6122,11 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
BindKind, StartLoc))
return StmtError();
+ // Report affected OpenMP target offloading behavior when in HIP lang-mode.
+ if (getLangOpts().HIP && (isOpenMPTargetExecutionDirective(Kind) ||
+ isOpenMPTargetDataManagementDirective(Kind)))
+ Diag(StartLoc, diag::warn_hip_omp_target_directives);
+
llvm::SmallVector<OMPClause *, 8> ClausesWithImplicit;
VarsWithInheritedDSAType VarsWithInheritedDSA;
bool ErrorFound = false;
@@ -13286,6 +13291,10 @@ StmtResult Sema::ActOnOpenMPTeamsDirective(ArrayRef<OMPClause *> Clauses,
if (!AStmt)
return StmtError();
+ // Report affected OpenMP target offloading behavior when in HIP lang-mode.
+ if (getLangOpts().HIP && (DSAStack->getParentDirective() == OMPD_target))
+ Diag(StartLoc, diag::warn_hip_omp_target_directives);
+
auto *CS = cast<CapturedStmt>(AStmt);
// 1.2.2 OpenMP Language Terminology
// Structured block - An executable statement with a single entry at the
@@ -22855,6 +22864,11 @@ bool Sema::ActOnStartOpenMPDeclareTargetContext(
Diag(DTCI.Loc, diag::err_omp_region_not_file_context);
return false;
}
+
+ // Report affected OpenMP target offloading behavior when in HIP lang-mode.
+ if (getLangOpts().HIP)
+ Diag(DTCI.Loc, diag::warn_hip_omp_target_directives);
+
DeclareTargetNesting.push_back(DTCI);
return true;
}
@@ -22927,6 +22941,10 @@ void Sema::ActOnOpenMPDeclareTargetName(NamedDecl *ND, SourceLocation Loc,
(ND->isUsed(/*CheckUsedAttr=*/false) || ND->isReferenced()))
Diag(Loc, diag::warn_omp_declare_target_after_first_use);
+ // Report affected OpenMP target offloading behavior when in HIP lang-mode.
+ if (getLangOpts().HIP)
+ Diag(Loc, diag::warn_hip_omp_target_directives);
+
// Explicit declare target lists have precedence.
const unsigned Level = -1;