Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions llvm/lib/Linker/IRMover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1562,10 +1562,6 @@ Error IRLinker::run() {
bool EnableDLWarning = true;
bool EnableTripleWarning = true;
if (SrcTriple.isNVPTX() && DstTriple.isNVPTX()) {
std::string ModuleId = SrcM->getModuleIdentifier();
StringRef FileName = llvm::sys::path::filename(ModuleId);
bool SrcIsLibDevice =
FileName.starts_with("libdevice") && FileName.ends_with(".10.bc");
bool SrcHasLibDeviceDL =
(SrcM->getDataLayoutStr().empty() ||
SrcM->getDataLayoutStr() == "e-i64:64-v16:16-v32:32-n16:32:64");
Expand All @@ -1576,8 +1572,8 @@ Error IRLinker::run() {
SrcTriple.getOSName() == "gpulibs") ||
(SrcTriple.getVendorName() == "unknown" &&
SrcTriple.getOSName() == "unknown");
EnableTripleWarning = !(SrcIsLibDevice && SrcHasLibDeviceTriple);
EnableDLWarning = !(SrcIsLibDevice && SrcHasLibDeviceDL);
EnableTripleWarning = !SrcHasLibDeviceTriple;
EnableDLWarning = !(SrcHasLibDeviceTriple && SrcHasLibDeviceDL);
}

if (EnableDLWarning && (SrcM->getDataLayout() != DstM.getDataLayout())) {
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/Linker/Inputs/libdevice-with-wrong-dl.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target triple = "nvptx64-nvidia-gpulibs"
target datalayout = "e-i64:64-i128:128-v32:32-n16:32:64"
10 changes: 5 additions & 5 deletions llvm/test/Linker/cuda-libdevice.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
; RUN: llvm-as %p/Inputs/libdevice-cuda-9.ll -o %t/libdevice.compute_35.10.bc
; RUN: llvm-as %p/Inputs/libdevice-cuda-10.ll -o %t/libdevice.10.bc
; RUN: llvm-as %p/Inputs/libdevice-cuda-11.ll -o %t/libdevice.11.10.bc
; RUN: llvm-as %p/Inputs/libdevice-cuda-9.ll -o %t/correct-libdevice-wrong-filename.bc
; RUN: llvm-as %p/Inputs/not-a-libdevice.ll -o %t/libdevice-with-wrong-info.bc
; RUN: llvm-as %p/Inputs/libdevice-with-wrong-dl.ll -o %t/libdevice-with-wrong-dl.bc

; No warnings expected when we link with libdevice variants
; RUN: llvm-link %t/main.bc %t/libdevice.compute_35.10.bc -S 2>&1 \
Expand All @@ -15,12 +15,12 @@
; RUN: llvm-link %t/main.bc %t/libdevice.11.10.bc -S 2>&1 \
; RUN: | FileCheck --check-prefixes COMMON,NOWARN %s

; But make sure we still issue warnings if we see unexpected filename, or
; unexpected triple or datalayout within a libdevice filename.
; RUN: llvm-link %t/main.bc %t/correct-libdevice-wrong-filename.bc -S 2>&1 \
; RUN: | FileCheck --check-prefixes COMMON,WARN-TRIPLE %s
; But make sure we still issue warnings if we see unexpected triple or
; datalayout within a libdevice module.
; RUN: llvm-link %t/main.bc %t/libdevice-with-wrong-info.bc -S 2>&1 \
; RUN: | FileCheck --check-prefixes COMMON,WARN-TRIPLE,WARN-DL %s
; RUN: llvm-link %t/main.bc %t/libdevice-with-wrong-dl.bc -S 2>&1 \
; RUN: | FileCheck --check-prefixes COMMON,NOWARN,WARN-DL %s


target triple = "nvptx64-nvidia-cuda"
Expand Down
Loading