From 7a0c6d549e862a9134bb776340d3a931f9e0f2e6 Mon Sep 17 00:00:00 2001 From: Arthurq Qiu Date: Wed, 1 Jan 2025 18:23:28 -0800 Subject: [PATCH] Remove libdevice filename check --- llvm/lib/Linker/IRMover.cpp | 8 ++------ llvm/test/Linker/Inputs/libdevice-with-wrong-dl.ll | 2 ++ llvm/test/Linker/cuda-libdevice.ll | 10 +++++----- 3 files changed, 9 insertions(+), 11 deletions(-) create mode 100644 llvm/test/Linker/Inputs/libdevice-with-wrong-dl.ll diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index a0c3f2c5b0baf..be3535ae94ff4 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -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"); @@ -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())) { diff --git a/llvm/test/Linker/Inputs/libdevice-with-wrong-dl.ll b/llvm/test/Linker/Inputs/libdevice-with-wrong-dl.ll new file mode 100644 index 0000000000000..bb000ef836cd4 --- /dev/null +++ b/llvm/test/Linker/Inputs/libdevice-with-wrong-dl.ll @@ -0,0 +1,2 @@ +target triple = "nvptx64-nvidia-gpulibs" +target datalayout = "e-i64:64-i128:128-v32:32-n16:32:64" diff --git a/llvm/test/Linker/cuda-libdevice.ll b/llvm/test/Linker/cuda-libdevice.ll index 484e8339a136e..87136b1773777 100644 --- a/llvm/test/Linker/cuda-libdevice.ll +++ b/llvm/test/Linker/cuda-libdevice.ll @@ -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 \ @@ -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"