diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.h')
-rw-r--r-- | contrib/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.h | 69 |
1 files changed, 61 insertions, 8 deletions
diff --git a/contrib/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.h b/contrib/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.h index cf3dbf59634d..b8bb6d85f005 100644 --- a/contrib/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.h +++ b/contrib/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.h @@ -105,6 +105,7 @@ struct OMPTaskDataTy final { SmallVector<const Expr *, 4> ReductionOrigs; SmallVector<const Expr *, 4> ReductionCopies; SmallVector<const Expr *, 4> ReductionOps; + SmallVector<CanonicalDeclPtr<const VarDecl>, 4> PrivateLocals; struct DependData { OpenMPDependClauseKind DepKind = OMPC_DEPEND_unknown; const Expr *IteratorExpr = nullptr; @@ -245,6 +246,19 @@ public: ~NontemporalDeclsRAII(); }; + /// Manages list of nontemporal decls for the specified directive. + class UntiedTaskLocalDeclsRAII { + CodeGenModule &CGM; + const bool NeedToPush; + + public: + UntiedTaskLocalDeclsRAII( + CodeGenFunction &CGF, + const llvm::DenseMap<CanonicalDeclPtr<const VarDecl>, + std::pair<Address, Address>> &LocalVars); + ~UntiedTaskLocalDeclsRAII(); + }; + /// Maps the expression for the lastprivate variable to the global copy used /// to store new value because original variables are not mapped in inner /// parallel regions. Only private copies are captured but we need also to @@ -292,6 +306,9 @@ protected: CodeGenModule &CGM; StringRef FirstSeparator, Separator; + /// An OpenMP-IR-Builder instance. + llvm::OpenMPIRBuilder OMPBuilder; + /// Constructor allowing to redefine the name separator for the variables. explicit CGOpenMPRuntime(CodeGenModule &CGM, StringRef FirstSeparator, StringRef Separator); @@ -372,11 +389,9 @@ protected: llvm::Value *getCriticalRegionLock(StringRef CriticalName); private: - /// An OpenMP-IR-Builder instance. - llvm::OpenMPIRBuilder OMPBuilder; /// Map for SourceLocation and OpenMP runtime library debug locations. - typedef llvm::DenseMap<unsigned, llvm::Value *> OpenMPDebugLocMapTy; + typedef llvm::DenseMap<SourceLocation, llvm::Value *> OpenMPDebugLocMapTy; OpenMPDebugLocMapTy OpenMPDebugLocMap; /// The type for a microtask which gets passed to __kmpc_fork_call(). /// Original representation is: @@ -418,6 +433,8 @@ private: std::tuple<QualType, const FieldDecl *, const FieldDecl *, LValue>>> LastprivateConditionalToTypes; + /// Maps function to the position of the untied task locals stack. + llvm::DenseMap<llvm::Function *, unsigned> FunctionToUntiedTaskStackMap; /// Type kmp_critical_name, originally defined as typedef kmp_int32 /// kmp_critical_name[8]; llvm::ArrayType *KmpCriticalNameTy; @@ -596,7 +613,8 @@ private: /// Return true if a target region entry with the provided information /// exists. bool hasTargetRegionEntryInfo(unsigned DeviceID, unsigned FileID, - StringRef ParentName, unsigned LineNum) const; + StringRef ParentName, unsigned LineNum, + bool IgnoreAddressId = false) const; /// brief Applies action \a Action on all registered entries. typedef llvm::function_ref<void(unsigned, unsigned, StringRef, unsigned, const OffloadEntryInfoTargetRegion &)> @@ -705,6 +723,11 @@ private: /// The set is the union of all current stack elements. llvm::SmallVector<NontemporalDeclsSet, 4> NontemporalDeclsStack; + using UntiedLocalVarsAddressesMap = + llvm::DenseMap<CanonicalDeclPtr<const VarDecl>, + std::pair<Address, Address>>; + llvm::SmallVector<UntiedLocalVarsAddressesMap, 4> UntiedLocalVarsStack; + /// Stack for list of addresses of declarations in current context marked as /// lastprivate conditional. The set is the union of all current stack /// elements. @@ -902,6 +925,10 @@ public: /// Emit the function for the user defined mapper construct. void emitUserDefinedMapper(const OMPDeclareMapperDecl *D, CodeGenFunction *CGF = nullptr); + /// Get the function for the specified user-defined mapper. If it does not + /// exist, create one. + llvm::Function * + getOrCreateUserDefinedMapperFunc(const OMPDeclareMapperDecl *D); /// Emits outlined function for the specified OpenMP parallel directive /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID, @@ -1600,6 +1627,9 @@ public: class TargetDataInfo { /// Set to true if device pointer information have to be obtained. bool RequiresDevicePointerInfo = false; + /// Set to true if Clang emits separate runtime calls for the beginning and + /// end of the region. These calls might have separate map type arrays. + bool SeparateBeginEndCalls = false; public: /// The array of base pointer passed to the runtime library. @@ -1608,8 +1638,21 @@ public: llvm::Value *PointersArray = nullptr; /// The array of sizes passed to the runtime library. llvm::Value *SizesArray = nullptr; - /// The array of map types passed to the runtime library. + /// The array of map types passed to the runtime library for the beginning + /// of the region or for the entire region if there are no separate map + /// types for the region end. llvm::Value *MapTypesArray = nullptr; + /// The array of map types passed to the runtime library for the end of the + /// region, or nullptr if there are no separate map types for the region + /// end. + llvm::Value *MapTypesArrayEnd = nullptr; + /// The array of user-defined mappers passed to the runtime library. + llvm::Value *MappersArray = nullptr; + /// The array of original declaration names of mapped pointers sent to the + /// runtime library for debugging + llvm::Value *MapNamesArray = nullptr; + /// Indicate whether any user-defined mapper exists. + bool HasMapper = false; /// The total number of pointers passed to the runtime library. unsigned NumberOfPtrs = 0u; /// Map between the a declaration of a capture and the corresponding base @@ -1617,22 +1660,29 @@ public: llvm::DenseMap<const ValueDecl *, Address> CaptureDeviceAddrMap; explicit TargetDataInfo() {} - explicit TargetDataInfo(bool RequiresDevicePointerInfo) - : RequiresDevicePointerInfo(RequiresDevicePointerInfo) {} + explicit TargetDataInfo(bool RequiresDevicePointerInfo, + bool SeparateBeginEndCalls) + : RequiresDevicePointerInfo(RequiresDevicePointerInfo), + SeparateBeginEndCalls(SeparateBeginEndCalls) {} /// Clear information about the data arrays. void clearArrayInfo() { BasePointersArray = nullptr; PointersArray = nullptr; SizesArray = nullptr; MapTypesArray = nullptr; + MapTypesArrayEnd = nullptr; + MapNamesArray = nullptr; + MappersArray = nullptr; + HasMapper = false; NumberOfPtrs = 0u; } /// Return true if the current target data information has valid arrays. bool isValid() { return BasePointersArray && PointersArray && SizesArray && - MapTypesArray && NumberOfPtrs; + MapTypesArray && (!HasMapper || MappersArray) && NumberOfPtrs; } bool requiresDevicePointerInfo() { return RequiresDevicePointerInfo; } + bool separateBeginEndCalls() { return SeparateBeginEndCalls; } }; /// Emit the target data mapping code associated with \a D. @@ -1841,6 +1891,9 @@ public: /// Destroys user defined allocators specified in the uses_allocators clause. void emitUsesAllocatorsFini(CodeGenFunction &CGF, const Expr *Allocator); + + /// Returns true if the variable is a local variable in untied task. + bool isLocalVarInUntiedTask(CodeGenFunction &CGF, const VarDecl *VD) const; }; /// Class supports emissionof SIMD-only code. |