diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp index bb887df3e4e04..8c4141db4341a 100644 --- a/clang/lib/CodeGen/CGCUDANV.cpp +++ b/clang/lib/CodeGen/CGCUDANV.cpp @@ -748,8 +748,12 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() { llvm::Constant *FatBinStr; unsigned FatMagic; if (IsHIP) { - FatbinConstantName = ".hip_fatbin"; - FatbinSectionName = ".hipFatBinSegment"; + FatbinConstantName = CGM.getTriple().isMacOSX() + ? "__HIP,__hip_fatbin" + : ".hip_fatbin"; + FatbinSectionName = CGM.getTriple().isMacOSX() + ? "__HIP,__fatbin" + : ".hipFatBinSegment"; ModuleIDSectionName = "__hip_module_id"; ModuleIDPrefix = "__hip_"; @@ -835,7 +839,7 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() { Linkage, /*Initializer=*/llvm::ConstantPointerNull::get(VoidPtrPtrTy), "__hip_gpubin_handle"); - if (Linkage == llvm::GlobalValue::LinkOnceAnyLinkage) + if (CGM.supportsCOMDAT() && (Linkage == llvm::GlobalValue::LinkOnceAnyLinkage)) GpuBinaryHandle->setComdat( CGM.getModule().getOrInsertComdat(GpuBinaryHandle->getName())); GpuBinaryHandle->setAlignment(CGM.getPointerAlign().getAsAlign()); diff --git a/clang/lib/Driver/ToolChains/HIPSPV.cpp b/clang/lib/Driver/ToolChains/HIPSPV.cpp index 78566ca9a6522..e4a3f439d9faa 100644 --- a/clang/lib/Driver/ToolChains/HIPSPV.cpp +++ b/clang/lib/Driver/ToolChains/HIPSPV.cpp @@ -96,8 +96,10 @@ void HIPSPV::Linker::constructLinkAndEmitSpirvCommand( } // Emit SPIR-V binary. - - llvm::opt::ArgStringList TrArgs{"--spirv-max-version=1.1", + // We need 1.2 when using warp-level primitivies via sub group extensions. + // Strictly put we'd need 1.3 for the standard non-extension shuffle + // operations, but it's not supported by any target yet. + llvm::opt::ArgStringList TrArgs{"--spirv-max-version=1.2", "--spirv-ext=+all"}; InputInfo TrInput = InputInfo(types::TY_LLVM_BC, TempFile, ""); SPIRV::constructTranslateCommand(C, *this, JA, Output, TrInput, TrArgs); @@ -285,8 +287,8 @@ VersionTuple HIPSPVToolChain::computeMSVCVersion(const Driver *D, void HIPSPVToolChain::adjustDebugInfoKind( codegenoptions::DebugInfoKind &DebugInfoKind, const llvm::opt::ArgList &Args) const { - // Debug info generation is disabled for SPIRV-LLVM-Translator - // which currently aborts on the presence of DW_OP_LLVM_convert. - // TODO: Enable debug info when the SPIR-V backend arrives. - DebugInfoKind = codegenoptions::NoDebugInfo; + + // Restrict the debug info to a kind compatible with llvm-spirv. + if (DebugInfoKind > codegenoptions::DebugLineTablesOnly) + DebugInfoKind = codegenoptions::DebugLineTablesOnly; } diff --git a/clang/tools/clang-linker-wrapper/OffloadWrapper.cpp b/clang/tools/clang-linker-wrapper/OffloadWrapper.cpp index dbfd896362c76..d84d0cc4765e0 100644 --- a/clang/tools/clang-linker-wrapper/OffloadWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/OffloadWrapper.cpp @@ -299,7 +299,7 @@ GlobalVariable *createFatbinDesc(Module &M, ArrayRef Image, bool IsHIP) { // Create the global string containing the fatbinary. StringRef FatbinConstantSection = - IsHIP ? ".hip_fatbin" + IsHIP ? (Triple.isMacOSX() ? "__HIP,__hip_fatbin" : ".hip_fatbin") : (Triple.isMacOSX() ? "__NV_CUDA,__nv_fatbin" : ".nv_fatbin"); auto *Data = ConstantDataArray::get(C, Image); auto *Fatbin = new GlobalVariable(M, Data->getType(), /*isConstant*/ true, @@ -308,7 +308,9 @@ GlobalVariable *createFatbinDesc(Module &M, ArrayRef Image, bool IsHIP) { Fatbin->setSection(FatbinConstantSection); // Create the fatbinary wrapper - StringRef FatbinWrapperSection = IsHIP ? ".hipFatBinSegment" + StringRef FatbinWrapperSection = IsHIP + ? Triple.isMacOSX() ? "__HIP,__fatbin" + : ".hipFatBinSegment" : Triple.isMacOSX() ? "__NV_CUDA,__fatbin" : ".nvFatBinSegment"; Constant *FatbinWrapper[] = {