llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clangir Author: Arseniy Obolenskiy (aobolensk) <details> <summary>Changes</summary> omp.parallel body already reads and writes the variables of the enclosing function directly --- Full diff: https://github.com/llvm/llvm-project/pull/241223.diff 4 Files Affected: - (modified) clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp (+2-3) - (modified) clang/test/CIR/CodeGenOpenMP/not-yet-implemented.c (-1) - (modified) clang/test/CIR/CodeGenOpenMP/parallel.c (+17) - (modified) clang/test/CIR/CodeGenOpenMP/target-parallel.c (+17) ``````````diff diff --git a/clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp b/clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp index 2b0e681989837..522285d71c27e 100644 --- a/clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp @@ -61,11 +61,10 @@ emitParallelClauses(CIRGenFunction &cgf, CIRGenModule &cgm, ce.emitNumThreads(clauseOps); ce.emitProcBind(clauseOps); return ce.emitNYI</*supported=*/OMPIfClause, OMPNumThreadsClause, - OMPProcBindClause>( + OMPProcBindClause, OMPSharedClause>( /*nyi=*/OpenMPNYIClauseList<OMPAllocateClause, OMPCopyinClause, OMPDefaultClause, OMPFirstprivateClause, - OMPPrivateClause, OMPReductionClause, - OMPSharedClause>{}, + OMPPrivateClause, OMPReductionClause>{}, llvm::omp::Directive::OMPD_parallel); } diff --git a/clang/test/CIR/CodeGenOpenMP/not-yet-implemented.c b/clang/test/CIR/CodeGenOpenMP/not-yet-implemented.c index c4a97e2b76d05..fab2047bfb17b 100644 --- a/clang/test/CIR/CodeGenOpenMP/not-yet-implemented.c +++ b/clang/test/CIR/CodeGenOpenMP/not-yet-implemented.c @@ -13,7 +13,6 @@ void do_things() { // A leaf that reports a not-yet-implemented clause emits no op at all, rather // than one that silently ignores the clause. int a, b; - // expected-error@+2{{ClangIR code gen Not Yet Implemented: OpenMP PARALLEL 'shared' clause}} // expected-error@+1{{ClangIR code gen Not Yet Implemented: OpenMP PARALLEL 'firstprivate' clause}} #pragma omp parallel shared(a) firstprivate(b) {} diff --git a/clang/test/CIR/CodeGenOpenMP/parallel.c b/clang/test/CIR/CodeGenOpenMP/parallel.c index 6a9a349c59489..09b691e070d0c 100644 --- a/clang/test/CIR/CodeGenOpenMP/parallel.c +++ b/clang/test/CIR/CodeGenOpenMP/parallel.c @@ -176,3 +176,20 @@ void num_threads_parallel() { // CHECK-NEXT: omp.terminator // CHECK-NEXT: } } + +void shared_parallel() { + // CHECK: cir.func{{.*}}@shared_parallel + int a; + // CHECK-NEXT: %[[A_ADDR:.*]] = cir.alloca "a" +#pragma omp parallel shared(a) + { + a = a + 1; + } + // CHECK-NEXT: omp.parallel { + // CHECK-NEXT: %[[A_LOAD:.*]] = cir.load align(4) %[[A_ADDR]] + // CHECK-NEXT: %[[ONE:.*]] = cir.const #cir.int<1> : !s32i + // CHECK-NEXT: %[[ADD:.*]] = cir.add nsw %[[A_LOAD]], %[[ONE]] : !s32i + // CHECK-NEXT: cir.store align(4) %[[ADD]], %[[A_ADDR]] : !s32i, !cir.ptr<!s32i> + // CHECK-NEXT: omp.terminator + // CHECK-NEXT: } +} diff --git a/clang/test/CIR/CodeGenOpenMP/target-parallel.c b/clang/test/CIR/CodeGenOpenMP/target-parallel.c index 3aad305e5a1b2..413e67f5a706b 100644 --- a/clang/test/CIR/CodeGenOpenMP/target-parallel.c +++ b/clang/test/CIR/CodeGenOpenMP/target-parallel.c @@ -57,3 +57,20 @@ void target_parallel_proc_bind(int x) { use(x); } } + +// 'target parallel' routes the shared clause to the parallel leaf. +void target_parallel_shared(int x) { + // CIR-HOST: cir.func{{.*}}@target_parallel_shared + // CIR-HOST: omp.target kernel_type(generic) map_entries({{.*}} -> %[[ARG:.*]] : !cir.ptr<!s32i>) { + // CIR-HOST: omp.parallel { + // CIR-HOST: %[[LOAD:.*]] = cir.load align(4) %[[ARG]] + // CIR-HOST: cir.call @use(%[[LOAD]]) + // CIR-HOST: omp.terminator + // CIR-HOST: } + // CIR-HOST: omp.terminator + // CIR-HOST: } {omp.combined} +#pragma omp target parallel shared(x) map(tofrom : x) + { + use(x); + } +} `````````` </details> https://github.com/llvm/llvm-project/pull/241223 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
