-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OpenMP] Clang Codegen Interop : Accept multiple init #82604
[OpenMP] Clang Codegen Interop : Accept multiple init #82604
Conversation
Changes to be committed: modified: clang/lib/CodeGen/CGStmtOpenMP.cpp
@llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: None (SunilKuravinakop) ChangesModifying clang/lib/CodeGen/CGStmtOpenMP.cpp to accept multiple Full diff: https://github.com/llvm/llvm-project/pull/82604.diff 1 Files Affected:
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 8fd74697de3c0f..c512b0bd851f7a 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -7023,19 +7023,25 @@ void CodeGenFunction::EmitOMPInteropDirective(const OMPInteropDirective &S) {
S.getSingleClause<OMPUseClause>())) &&
"OMPNowaitClause clause is used separately in OMPInteropDirective.");
- if (const auto *C = S.getSingleClause<OMPInitClause>()) {
- llvm::Value *InteropvarPtr =
- EmitLValue(C->getInteropVar()).getPointer(*this);
- llvm::omp::OMPInteropType InteropType = llvm::omp::OMPInteropType::Unknown;
- if (C->getIsTarget()) {
- InteropType = llvm::omp::OMPInteropType::Target;
- } else {
- assert(C->getIsTargetSync() && "Expected interop-type target/targetsync");
- InteropType = llvm::omp::OMPInteropType::TargetSync;
+ auto It = S.getClausesOfKind<OMPInitClause>();
+ if (!It.empty()) {
+ // Look at the multiple init clauses
+ for (auto C : It) {
+ llvm::Value *InteropvarPtr =
+ EmitLValue(C->getInteropVar()).getPointer(*this);
+ llvm::omp::OMPInteropType InteropType =
+ llvm::omp::OMPInteropType::Unknown;
+ if (C->getIsTarget()) {
+ InteropType = llvm::omp::OMPInteropType::Target;
+ } else {
+ assert(C->getIsTargetSync() &&
+ "Expected interop-type target/targetsync");
+ InteropType = llvm::omp::OMPInteropType::TargetSync;
+ }
+ OMPBuilder.createOMPInteropInit(Builder, InteropvarPtr, InteropType,
+ Device, NumDependences, DependenceList,
+ Data.HasNowaitClause);
}
- OMPBuilder.createOMPInteropInit(Builder, InteropvarPtr, InteropType, Device,
- NumDependences, DependenceList,
- Data.HasNowaitClause);
} else if (const auto *C = S.getSingleClause<OMPDestroyClause>()) {
llvm::Value *InteropvarPtr =
EmitLValue(C->getInteropVar()).getPointer(*this);
|
The test is required |
provided twice. This check is being done only for AMD GPU. Changes to be committed: new file: clang/test/OpenMP/interop_codegen.cpp
-fopenmp-targets=powerpc64le-ibm-linux-gnu. Changes to be committed: modified: clang/test/OpenMP/interop_codegen.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
Outdated
auto It = S.getClausesOfKind<OMPInitClause>(); | ||
if (!It.empty()) { | ||
// Look at the multiple init clauses | ||
for (auto C : It) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expand 'auto' here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the Iterator variable It
auto It
is preferable rather than
llvm::iterator_range<clang::OMPExecutableDirective::specific_clause_iterator<clang::OMPInitClause> > It
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C is just OMPClause * here, not an iterator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asking about auto for C, not for It.
…*C : It)". Changes to be committed: modified: clang/lib/CodeGen/CGStmtOpenMP.cpp
Changes to be committed: modified: clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
Outdated
auto It = S.getClausesOfKind<OMPInitClause>(); | ||
if (!It.empty()) { | ||
// Look at the multiple init clauses | ||
for (const class OMPInitClause *C : It) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop 'class', it won't compile
Changes to be committed: modified: clang/lib/CodeGen/CGStmtOpenMP.cpp modified: clang/test/OpenMP/interop_codegen.cpp
The recent commit also takes care of the feedback provided by Alexey. |
clang/lib/CodeGen/CGStmtOpenMP.cpp
Outdated
auto ItOMPDestroyClause = S.getClausesOfKind<OMPDestroyClause>(); | ||
if (!ItOMPDestroyClause.empty()) { | ||
// Look at the multiple destroy clauses | ||
for (const OMPDestroyClause *C : ItOMPDestroyClause) { | ||
llvm::Value *InteropvarPtr = | ||
EmitLValue(C->getInteropVar()).getPointer(*this); | ||
OMPBuilder.createOMPInteropDestroy(Builder, InteropvarPtr, Device, | ||
NumDependences, DependenceList, | ||
Data.HasNowaitClause); | ||
} | ||
} | ||
auto ItOMPUseClause = S.getClausesOfKind<OMPUseClause>(); | ||
if (!ItOMPUseClause.empty()) { | ||
// Look at the multiple use clauses | ||
for (const OMPUseClause *C : ItOMPUseClause) { | ||
llvm::Value *InteropvarPtr = | ||
EmitLValue(C->getInteropVar()).getPointer(*this); | ||
OMPBuilder.createOMPInteropUse(Builder, InteropvarPtr, Device, | ||
NumDependences, DependenceList, | ||
Data.HasNowaitClause); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split it to a separate patch
merge. Changes to be committed: modified: clang/lib/CodeGen/CGStmtOpenMP.cpp modified: clang/test/OpenMP/interop_codegen.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG
Modifying clang/lib/CodeGen/CGStmtOpenMP.cpp to accept multiple
init
clauses withinterop
directive.