diff options
Diffstat (limited to 'llvm/lib/Frontend/OpenMP/OMP.cpp')
| -rw-r--r-- | llvm/lib/Frontend/OpenMP/OMP.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/lib/Frontend/OpenMP/OMP.cpp b/llvm/lib/Frontend/OpenMP/OMP.cpp index 9e625b809de9..f12941492547 100644 --- a/llvm/lib/Frontend/OpenMP/OMP.cpp +++ b/llvm/lib/Frontend/OpenMP/OMP.cpp @@ -9,6 +9,8 @@ #include "llvm/Frontend/OpenMP/OMP.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Sequence.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Demangle/Demangle.h" @@ -75,6 +77,26 @@ getFirstCompositeRange(iterator_range<ArrayRef<Directive>::iterator> Leafs) { return llvm::make_range(Begin, End); } +static void +collectPrivatizingConstructs(llvm::SmallSet<Directive, 16> &Constructs, + unsigned Version) { + llvm::SmallSet<Clause, 16> Privatizing; + for (auto C : + llvm::enum_seq_inclusive<Clause>(Clause::First_, Clause::Last_)) { + if (isPrivatizingClause(C)) + Privatizing.insert(C); + } + + for (auto D : llvm::enum_seq_inclusive<Directive>(Directive::First_, + Directive::Last_)) { + bool AllowsPrivatizing = llvm::any_of(Privatizing, [&](Clause C) { + return isAllowedClauseForDirective(D, C, Version); + }); + if (AllowsPrivatizing) + Constructs.insert(D); + } +} + namespace llvm::omp { ArrayRef<Directive> getLeafConstructs(Directive D) { auto Idx = static_cast<std::size_t>(D); @@ -194,6 +216,18 @@ ArrayRef<unsigned> getOpenMPVersions() { return Versions; } +bool isPrivatizingConstruct(Directive D, unsigned Version) { + static llvm::SmallSet<Directive, 16> Privatizing; + [[maybe_unused]] static bool Init = + (collectPrivatizingConstructs(Privatizing, Version), true); + + // As of OpenMP 6.0, privatizing constructs (with the test being if they + // allow a privatizing clause) are: dispatch, distribute, do, for, loop, + // parallel, scope, sections, simd, single, target, target_data, task, + // taskgroup, taskloop, and teams. + return llvm::is_contained(Privatizing, D); +} + std::string prettifyFunctionName(StringRef FunctionName) { // Internalized functions have the right name, but simply a suffix. if (FunctionName.ends_with(".internalized")) |
