Skip to content
Open
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
5 changes: 5 additions & 0 deletions mlir/lib/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ AMDGPUSerializer::loadBitcodeFiles(llvm::Module &module) {
", error message:" + error.getMessage());
return std::nullopt;
}
// Packaged libraries can come from a newer LLVM than ours. Give them the
// same handling as libraries loaded from disk so they adopt our triple
// and data layout instead of warning on every kernel that links them.
if (failed(handleBitcodeFile(*library)))
return std::nullopt;
// Unset the lib so we don't add it with `appendStandardLibs`.
libs = libs & ~lib;
bcFiles.push_back(std::move(library));
Expand Down
17 changes: 17 additions & 0 deletions mlir/test/Target/packaged-device-libs.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RUN: rocmlir-opt %s --rocdl-attach-target=chip=gfx942 --gpu-module-to-binary 2>&1 \
// RUN: | FileCheck %s --implicit-check-not="Linking two modules"

// The packaged device libraries can be built by a newer LLVM than ours, with a
// different triple spelling and data layout. Linking them must not warn.

// CHECK: gpu.binary @kernels
module attributes {gpu.container_module} {
gpu.module @kernels {
llvm.func @__ocml_exp_f32(f32) -> f32
llvm.func @kernel(%arg0: f32, %arg1: !llvm.ptr<1>) attributes {rocdl.kernel} {
%0 = llvm.call @__ocml_exp_f32(%arg0) : (f32) -> f32
llvm.store %0, %arg1 : f32, !llvm.ptr<1>
llvm.return
}
}
}
Loading