diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h index 78505d66d6f2f..3b67e8ca55ae7 100644 --- a/clang/lib/Basic/Targets/SPIR.h +++ b/clang/lib/Basic/Targets/SPIR.h @@ -374,6 +374,20 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64TargetInfo : public BaseSPIRVTargetInfo { const llvm::omp::GV &getGridValue() const override { return llvm::omp::SPIRVGridValues; } + + std::optional getConstantAddressSpace() const override { + return ConstantAS; + } + void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override { + BaseSPIRVTargetInfo::adjust(Diags, Opts); + // opencl_constant will map to UniformConstant in SPIR-V + if (Opts.OpenCL) + ConstantAS = LangAS::opencl_constant; + } + +private: + // opencl_global will map to CrossWorkgroup in SPIR-V + LangAS ConstantAS = LangAS::opencl_global; }; class LLVM_LIBRARY_VISIBILITY SPIRV64AMDGCNTargetInfo final diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index 68b1fa42934ad..998702c1af3cd 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -6295,6 +6295,12 @@ OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createTargetInit( : ConstantExpr::getAddrSpaceCast(KernelEnvironmentGV, KernelEnvironmentPtr); Value *KernelLaunchEnvironment = DebugKernelWrapper->getArg(0); + Type *KernelLaunchEnvParamTy = Fn->getFunctionType()->getParamType(1); + KernelLaunchEnvironment = + KernelLaunchEnvironment->getType() == KernelLaunchEnvParamTy + ? KernelLaunchEnvironment + : Builder.CreateAddrSpaceCast(KernelLaunchEnvironment, + KernelLaunchEnvParamTy); CallInst *ThreadKind = Builder.CreateCall(Fn, {KernelEnvironment, KernelLaunchEnvironment});