Skip to content

Commit face93e

Browse files
authored
[Frontend][OpenMP] Move isPrivatizingClause to OMP.h, NFC (#148644)
1 parent d26106d commit face93e

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -795,25 +795,9 @@ bool ConstructDecompositionT<C, H>::applyClause(
795795
// assigned to which leaf constructs.
796796

797797
// [5.2:340:33]
798-
auto canMakePrivateCopy = [](llvm::omp::Clause id) {
799-
switch (id) {
800-
// Clauses with "privatization" property:
801-
case llvm::omp::Clause::OMPC_firstprivate:
802-
case llvm::omp::Clause::OMPC_in_reduction:
803-
case llvm::omp::Clause::OMPC_lastprivate:
804-
case llvm::omp::Clause::OMPC_linear:
805-
case llvm::omp::Clause::OMPC_private:
806-
case llvm::omp::Clause::OMPC_reduction:
807-
case llvm::omp::Clause::OMPC_task_reduction:
808-
return true;
809-
default:
810-
return false;
811-
}
812-
};
813-
814798
bool applied = applyIf(node, [&](const auto &leaf) {
815799
return llvm::any_of(leaf.clauses, [&](const ClauseTy *n) {
816-
return canMakePrivateCopy(n->id);
800+
return llvm::omp::isPrivatizingClause(n->id);
817801
});
818802
});
819803

llvm/include/llvm/Frontend/OpenMP/OMP.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ static constexpr inline bool canHaveIterator(Clause C) {
4848
}
4949
}
5050

51+
// Can clause C create a private copy of a variable.
52+
static constexpr inline bool isPrivatizingClause(Clause C) {
53+
switch (C) {
54+
case OMPC_firstprivate:
55+
case OMPC_in_reduction:
56+
case OMPC_lastprivate:
57+
case OMPC_linear:
58+
case OMPC_private:
59+
case OMPC_reduction:
60+
case OMPC_task_reduction:
61+
return true;
62+
default:
63+
return false;
64+
}
65+
}
66+
5167
static constexpr unsigned FallbackVersion = 52;
5268
LLVM_ABI ArrayRef<unsigned> getOpenMPVersions();
5369

0 commit comments

Comments
 (0)