Author: Dominik Adamski Date: 2023-04-21T01:35:39-05:00 New Revision: f90056767828e499f4cdf568968e19cf8b6ab81b
URL: https://github.com/llvm/llvm-project/commit/f90056767828e499f4cdf568968e19cf8b6ab81b DIFF: https://github.com/llvm/llvm-project/commit/f90056767828e499f4cdf568968e19cf8b6ab81b.diff LOG: [OpenMP][AMDGPU] Refactor setting uniform work group size attribute Work group size attribute was set in Clang specific class. That's why we cannot reuse this code in Flang. If we move setting of this attribute to OpenMPIRBuilder, then we can reuse this code in Flang and Clang. Function createOffloadEntry from OpenMPIRBuilder is already used by Clang (via OpenMPIRBuilder::createOffloadEntriesAndInfoMetadata function). Differential Revision: https://reviews.llvm.org/D148525 Reviewed By: jdoerfert Added: Modified: clang/lib/CodeGen/TargetInfo.cpp llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index e50e07a531b55..cc332aeee40d4 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -9588,12 +9588,9 @@ void AMDGPUTargetCodeGenInfo::setTargetAttributes( const bool IsHIPKernel = M.getLangOpts().HIP && FD && FD->hasAttr<CUDAGlobalAttr>(); - const bool IsOpenMPkernel = - M.getLangOpts().OpenMPIsDevice && - (F->getCallingConv() == llvm::CallingConv::AMDGPU_KERNEL); // TODO: This should be moved to language specific attributes instead. - if (IsHIPKernel || IsOpenMPkernel) + if (IsHIPKernel) F->addFnAttr("uniform-work-group-size", "true"); if (M.getContext().getTargetInfo().allowAMDGPUUnsafeFPAtomics()) diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index 12c7c42ac5fe5..cf329e40f5a44 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -4892,6 +4892,8 @@ void OpenMPIRBuilder::createOffloadEntry(Constant *ID, Constant *Addr, // Add a function attribute for the kernel. Fn->addFnAttr(Attribute::get(Ctx, "kernel")); + if (Triple(M.getTargetTriple()).isAMDGCN()) + Fn->addFnAttr("uniform-work-group-size", "true"); } // We only generate metadata for function that contain target regions. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits