@@ -840,8 +840,10 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
840
840
FatBinStr = new llvm::GlobalVariable (
841
841
CGM.getModule (), CGM.Int8Ty ,
842
842
/* isConstant=*/ true , llvm::GlobalValue::ExternalLinkage, nullptr ,
843
- " __hip_fatbin_" + CGM.getContext ().getCUIDHash (), nullptr ,
844
- llvm::GlobalVariable::NotThreadLocal);
843
+ " __hip_fatbin" + (CGM.getLangOpts ().CUID .empty ()
844
+ ? " "
845
+ : " _" + CGM.getContext ().getCUIDHash ()),
846
+ nullptr , llvm::GlobalVariable::NotThreadLocal);
845
847
cast<llvm::GlobalVariable>(FatBinStr)->setSection (FatbinConstantName);
846
848
}
847
849
@@ -894,8 +896,8 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
894
896
// thread safety of the loaded program. Therefore we can assume sequential
895
897
// execution of constructor functions here.
896
898
if (IsHIP) {
897
- auto Linkage = CudaGpuBinary ? llvm::GlobalValue::InternalLinkage
898
- : llvm::GlobalValue::ExternalLinkage ;
899
+ auto Linkage = RelocatableDeviceCode ? llvm::GlobalValue::ExternalLinkage
900
+ : llvm::GlobalValue::InternalLinkage ;
899
901
llvm::BasicBlock *IfBlock =
900
902
llvm::BasicBlock::Create (Context, " if" , ModuleCtorFunc);
901
903
llvm::BasicBlock *ExitBlock =
@@ -905,10 +907,11 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
905
907
GpuBinaryHandle = new llvm::GlobalVariable (
906
908
TheModule, PtrTy, /* isConstant=*/ false , Linkage,
907
909
/* Initializer=*/
908
- CudaGpuBinary ? llvm::ConstantPointerNull::get (PtrTy) : nullptr ,
909
- CudaGpuBinary
910
- ? " __hip_gpubin_handle"
911
- : " __hip_gpubin_handle_" + CGM.getContext ().getCUIDHash ());
910
+ !RelocatableDeviceCode ? llvm::ConstantPointerNull::get (PtrTy)
911
+ : nullptr ,
912
+ " __hip_gpubin_handle" + (CGM.getLangOpts ().CUID .empty ()
913
+ ? " "
914
+ : " _" + CGM.getContext ().getCUIDHash ()));
912
915
GpuBinaryHandle->setAlignment (CGM.getPointerAlign ().getAsAlign ());
913
916
// Prevent the weak symbol in different shared libraries being merged.
914
917
if (Linkage != llvm::GlobalValue::InternalLinkage)
0 commit comments