Author: abataev Date: Mon Nov 27 08:54:08 2017 New Revision: 319046 URL: http://llvm.org/viewvc/llvm-project?rev=319046&view=rev Log: [OPENMP] Improve handling of cancel directives in target-based constructs, NFC.
Improved handling of cancel|cancellation point directives inside target-based for directives. Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=319046&r1=319045&r2=319046&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Nov 27 08:54:08 2017 @@ -1293,6 +1293,13 @@ static llvm::Value *emitParallelOrTeamsO HasCancel = OPFD->hasCancel(); else if (auto *OPFD = dyn_cast<OMPTargetParallelForDirective>(&D)) HasCancel = OPFD->hasCancel(); + else if (auto *OPFD = dyn_cast<OMPDistributeParallelForDirective>(&D)) + HasCancel = OPFD->hasCancel(); + else if (auto *OPFD = dyn_cast<OMPTeamsDistributeParallelForDirective>(&D)) + HasCancel = OPFD->hasCancel(); + else if (auto *OPFD = + dyn_cast<OMPTargetTeamsDistributeParallelForDirective>(&D)) + HasCancel = OPFD->hasCancel(); CGOpenMPOutlinedRegionInfo CGInfo(*CS, ThreadIDVar, CodeGen, InnermostKind, HasCancel, OutlinedHelperName); CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo); Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=319046&r1=319045&r2=319046&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original) +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Nov 27 08:54:08 2017 @@ -2039,8 +2039,7 @@ void CodeGenFunction::EmitOMPDistributeP S.getDistInc()); }; OMPLexicalScope Scope(*this, S, /*AsInlined=*/true); - CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_distribute, CodeGen, - S.hasCancel()); + CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_distribute, CodeGen); } void CodeGenFunction::EmitOMPDistributeParallelForSimdDirective( @@ -3201,8 +3200,7 @@ void CodeGenFunction::EmitOMPDistributeD CGF.EmitOMPDistributeLoop(S, emitOMPLoopBodyWithStopPoint, S.getInc()); }; OMPLexicalScope Scope(*this, S, /*AsInlined=*/true); - CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_distribute, CodeGen, - false); + CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_distribute, CodeGen); } static llvm::Function *emitOutlinedOrderedFunction(CodeGenModule &CGM, @@ -3915,8 +3913,8 @@ void CodeGenFunction::EmitOMPTeamsDistri OMPPrivateScope PrivateScope(CGF); CGF.EmitOMPReductionClauseInit(S, PrivateScope); (void)PrivateScope.Privatize(); - CGF.CGM.getOpenMPRuntime().emitInlinedDirective( - CGF, OMPD_distribute, CodeGenDistribute, S.hasCancel()); + CGF.CGM.getOpenMPRuntime().emitInlinedDirective(CGF, OMPD_distribute, + CodeGenDistribute); CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_teams); }; emitCommonOMPTeamsDirective(*this, S, OMPD_distribute_parallel_for, CodeGen); Modified: cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp?rev=319046&r1=319045&r2=319046&view=diff ============================================================================== --- cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp Mon Nov 27 08:54:08 2017 @@ -106,6 +106,7 @@ int foo(int n) { #pragma omp target parallel for for (int i = 3; i < 32; i += 5) { #pragma omp cancel for +#pragma omp cancellation point for } // CHECK: call void [[HVT1:@.+]](i[[SZ]] {{[^,]+}}, i{{32|64}}{{[*]*}} {{[^)]+}}) @@ -325,6 +326,7 @@ int foo(int n) { // // CHECK: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias %.global_tid., i32* noalias %.bound_tid.) // CHECK: call i32 @__kmpc_cancel(%ident_t* @ +// CHECK: call i32 @__kmpc_cancellationpoint(%ident_t* @ // CHECK: ret void // CHECK: } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits