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(); - 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.