This revision was automatically updated to reflect the committed changes. Closed by commit rC361880: [CUDA][HIP] Emit dependent libs for host only (authored by yaxunl, committed by ). Herald added a project: clang.
Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D62483/new/ https://reviews.llvm.org/D62483 Files: lib/CodeGen/CodeGenModule.cpp test/CodeGenCUDA/dependent-libs.cu Index: test/CodeGenCUDA/dependent-libs.cu =================================================================== --- test/CodeGenCUDA/dependent-libs.cu +++ test/CodeGenCUDA/dependent-libs.cu @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -emit-llvm -o - -fcuda-is-device -x hip %s | FileCheck --check-prefix=DEV %s +// RUN: %clang_cc1 -emit-llvm -o - -x hip %s | FileCheck --check-prefix=HOST %s + +// DEV-NOT: llvm.dependent-libraries +// HOST: llvm.dependent-libraries +#pragma comment(lib, "libabc") Index: lib/CodeGen/CodeGenModule.cpp =================================================================== --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -457,7 +457,12 @@ // that ELF linkers tend to handle libraries in a more complicated fashion // than on other platforms. This forces us to defer handling the dependent // libs to the linker. - if (!ELFDependentLibraries.empty()) { + // + // CUDA/HIP device and host libraries are different. Currently there is no + // way to differentiate dependent libraries for host or device. Existing + // usage of #pragma comment(lib, *) is intended for host libraries on + // Windows. Therefore emit llvm.dependent-libraries only for host. + if (!ELFDependentLibraries.empty() && !Context.getLangOpts().CUDAIsDevice) { auto *NMD = getModule().getOrInsertNamedMetadata("llvm.dependent-libraries"); for (auto *MD : ELFDependentLibraries) NMD->addOperand(MD);
Index: test/CodeGenCUDA/dependent-libs.cu =================================================================== --- test/CodeGenCUDA/dependent-libs.cu +++ test/CodeGenCUDA/dependent-libs.cu @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -emit-llvm -o - -fcuda-is-device -x hip %s | FileCheck --check-prefix=DEV %s +// RUN: %clang_cc1 -emit-llvm -o - -x hip %s | FileCheck --check-prefix=HOST %s + +// DEV-NOT: llvm.dependent-libraries +// HOST: llvm.dependent-libraries +#pragma comment(lib, "libabc") Index: lib/CodeGen/CodeGenModule.cpp =================================================================== --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -457,7 +457,12 @@ // that ELF linkers tend to handle libraries in a more complicated fashion // than on other platforms. This forces us to defer handling the dependent // libs to the linker. - if (!ELFDependentLibraries.empty()) { + // + // CUDA/HIP device and host libraries are different. Currently there is no + // way to differentiate dependent libraries for host or device. Existing + // usage of #pragma comment(lib, *) is intended for host libraries on + // Windows. Therefore emit llvm.dependent-libraries only for host. + if (!ELFDependentLibraries.empty() && !Context.getLangOpts().CUDAIsDevice) { auto *NMD = getModule().getOrInsertNamedMetadata("llvm.dependent-libraries"); for (auto *MD : ELFDependentLibraries) NMD->addOperand(MD);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits