This revision was automatically updated to reflect the committed changes. Closed by commit rGa969e051a5d9: [OpenMP] Add Flush directive to OpenMPIRBuilder (authored by kiranchandramohan). Herald added a project: clang. Herald added a subscriber: cfe-commits.
Changed prior to commit: https://reviews.llvm.org/D70712?vs=231520&id=242438#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70712/new/ https://reviews.llvm.org/D70712 Files: clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/test/OpenMP/flush_codegen.cpp llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h llvm/include/llvm/Frontend/OpenMP/OMPKinds.def llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp =================================================================== --- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -630,3 +630,19 @@ return AfterIP; } + +void OpenMPIRBuilder::emitFlush(const LocationDescription &Loc) +{ + // Build call void __kmpc_flush(ident_t *loc) + Constant *SrcLocStr = getOrCreateSrcLocStr(Loc); + Value *Args[] = {getOrCreateIdent(SrcLocStr)}; + + Builder.CreateCall(getOrCreateRuntimeFunction(OMPRTL___kmpc_flush), Args); +} + +void OpenMPIRBuilder::CreateFlush(const LocationDescription &Loc) +{ + if (!updateToLocation(Loc)) + return; + emitFlush(Loc); +} Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def =================================================================== --- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def +++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def @@ -166,6 +166,7 @@ __OMP_RTL(__kmpc_barrier, false, Void, IdentPtr, Int32) __OMP_RTL(__kmpc_cancel, false, Int32, IdentPtr, Int32, Int32) __OMP_RTL(__kmpc_cancel_barrier, false, Int32, IdentPtr, Int32) +__OMP_RTL(__kmpc_flush, false, Void, IdentPtr) __OMP_RTL(__kmpc_global_thread_num, false, Int32, IdentPtr) __OMP_RTL(__kmpc_fork_call, true, Void, IdentPtr, Int32, ParallelTaskPtr) __OMP_RTL(__kmpc_push_num_threads, false, Void, IdentPtr, Int32, Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h =================================================================== --- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h +++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h @@ -168,8 +168,14 @@ Value *IfCondition, Value *NumThreads, omp::ProcBindKind ProcBind, bool IsCancellable); + /// Generator for '#omp flush' + /// + /// \param Loc The location where the flush directive was encountered + void CreateFlush(const LocationDescription &Loc); + ///} + private: /// Update the internal location to \p Loc. bool updateToLocation(const LocationDescription &Loc) { @@ -214,6 +220,11 @@ omp::Directive DK, bool ForceSimpleCall, bool CheckCancelFlag); + /// Generate a flush runtime call. + /// + /// \param Loc The location at which the request originated and is fulfilled. + void emitFlush(const LocationDescription &Loc); + /// The finalization stack made up of finalize callbacks currently in-flight, /// wrapped into FinalizationInfo objects that reference also the finalization /// target block and the kind of cancellable directive. Index: clang/test/OpenMP/flush_codegen.cpp =================================================================== --- clang/test/OpenMP/flush_codegen.cpp +++ clang/test/OpenMP/flush_codegen.cpp @@ -1,6 +1,9 @@ // RUN: %clang_cc1 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp =================================================================== --- clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -3876,11 +3876,16 @@ void CGOpenMPRuntime::emitFlush(CodeGenFunction &CGF, ArrayRef<const Expr *>, SourceLocation Loc) { - if (!CGF.HaveInsertPoint()) - return; - // Build call void __kmpc_flush(ident_t *loc) - CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_flush), - emitUpdateLocation(CGF, Loc)); + llvm::OpenMPIRBuilder *OMPBuilder = CGF.CGM.getOpenMPIRBuilder(); + if (OMPBuilder) { + OMPBuilder->CreateFlush(CGF.Builder); + } else { + if (!CGF.HaveInsertPoint()) + return; + // Build call void __kmpc_flush(ident_t *loc) + CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_flush), + emitUpdateLocation(CGF, Loc)); + } } namespace {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits